Skip to content

Conversation

@JosephLenton
Copy link

@JosephLenton JosephLenton commented Aug 20, 2024

This adds support for base_url to the client when making a request.

Changes

  • Add ClientBuilder::base_url for setting a base url for the client.
  • Change Client::send to use the base url, if it is set.

Implements #988

Comment on lines +1998 to +2481
Some(ref base_url) => Url::options()
.base_url(Some(base_url))
.parse(url.as_str())
.map_err(crate::error::builder)
.and_then(IntoUrlSealed::into_url),
Copy link
Author

Choose a reason for hiding this comment

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

This is the only part of the code I find suspect, as maybe this should live in IntoUrl. I was not too sure on the best way to make changes there without changing the trait (that I was trying to avoid).

For the base_url behaviour, I have deferred to how it is implemented in the Url crate. This is documented here: https://docs.rs/url/latest/url/struct.Url.html#method.join

@JosephLenton
Copy link
Author

Hey @peddermaster2 , thanks for your approval! I have rebased it and fixed the git conflicts.

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