-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Hex API and CDN URLs configurable #36
base: main
Are you sure you want to change the base?
Make Hex API and CDN URLs configurable #36
Conversation
@@ -27,7 +27,7 @@ regex = "1.3" | |||
# Byte collections | |||
bytes = "1" | |||
# Protobuf runtime | |||
protobuf = "3.4" | |||
protobuf = "=3.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version 3.7.1 of the protobuf crate has been released and failed the build.
But I didn't want to overload this PR so I am going to bump the protobuf version and regenerate the files in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See: PR #37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, but it's not appropriate for a library to be configured using environment variables or to print to the console or to halt the program, those are impure actions that applications would need to opt-in to and perform themselves. Instead the configuration would need to be passed in, and then the applications can decide what would be an appropriate manner to decide what to set those values to.
Could you convert that over please? Then we can read environment variables in the Gleam build tool 🙏
This change aligns better with Rust conventions by using Default to provide standard Hex URLs, making the common case easier and more idiomatic. Since Config has well-defined defaults (hex.pm URLs), implementing Default is more appropriate than using a new() constructor.
Yes, that makes way more sense! Configuration and Breaking ChangesI hope it's ok that I introduced a breaking change to use // Use default API URL and repository URL
let config = Config::default()
// Use custom API URL and default repository URL
let config = Config::default()
.with_custom_api("https://example.com/api/".parse().unwrap());
// Use default API URL and custom repository URL
let config = Config::default()
.with_custom_repository("https://repo.example.com/".parse().unwrap());
// Use custom URLs for both
let config = Config::default()
.with_custom_api("https://example.com/api/".parse().unwrap())
.with_custom_repository("https://repo.example.com/".parse().unwrap()); The default is to use the standard Hex URLs without having to set them explicitly at all, so using Naming and ConsistencyYou proposed In the context of this library we use |
133b4e8
to
b06dcab
Compare
This PR is regarding issue gleam-lang/gleam#2817 and allows for configuration of Hex URLs.
Breaking Change
It changes the primary way to create a Config from
Config::new()
toConfig::default()
.Configuration
It introduces two builder methods for customizing the Hex URLs independently:
with_custom_api
allows setting a custom API URLwith_custom_repository
allows setting a custom repository URLThese methods can be used individually or chained together when both URLs need to be customized: