Skip to content
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

feat: add base_url parsing #2399

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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 +2002
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 JosephLenton marked this pull request as ready for review August 24, 2024 09:03
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.

1 participant