Skip to content

Conversation

@0xN1nja
Copy link
Contributor

@0xN1nja 0xN1nja commented Jan 4, 2026

Simplify credential configuration by accepting a single base_url parameter instead of setting up host, port, and scheme manually by the constructor functions with_port and with_scheme.

Parsing base_url by gleam/uri to get host, port, and scheme:

pub fn credentials(
  base_url: String,
  access_key_id: String,
  secret_access_key: String,
) -> Credentials {
  let assert Ok(parsed_url) = uri.parse(base_url)

  Credentials(
    host: parsed_url.host,
    port: parsed_url.port,
    scheme: parsed_url.scheme,
    region: "eu-west-1",
    access_key_id:,
    secret_access_key:,
    session_token: option.None,
  )
}

User can now specify a base_url in bucket.credentials, and gleam/uri would automatically parse the URI in the background.

let creds = bucket.credentials(
  base_url: "https://s3-api-host.example.com:port",
  access_key_id: "YOUR_ACCESS_KEY",
  secret_access_key: "YOUR_SECRET_ACCESS_KEY",
)

Copy link
Owner

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has replaced type safety for runtime exceptions, and it introduces a breaking change, neither of which we want.

Please do not open a PR for unplanned changes, instead make an issue first 🙏

access_key_id: String,
secret_access_key: String,
) -> Credentials {
let assert Ok(parsed_url) = uri.parse(base_url)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Libraries must never panic!

@lpil lpil closed this Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants