reqwest
reqwest copied to clipboard
Add base url option to ClientBuilder
Closes #213, closes #988
There is still one possible problem with this implementation that I don't know if it should be addressed or not.
If the base_url
is set to: http://example.com
and the Client
makes a request to a
(not /a
), it would make a request to http://example.coma
. I could easily add a check to see if the string ends with /
and if it's not there I just add it. However, if I implement this, and we consider the same scenario, then a get to /a
would actually make a request to http://example.com//a
(note the double /
). I could implement a check for this too and check for a string beginning with /
and remove it if so.
I didn't do any of these because I didn't want to make this PR unnecessarily complex and/or implement something that a user would consider unexpected behavior without hearing any feedback first.
Edit: I implemented these checks over at base_url_check
After using my own fork, I found it better to use this with those checks so I merged them into this PR
This PR would also close #988.
Any updates?
What can we do to land this?
Any updates on this?
Just rebased the branch. This is now over a year old.
Can we get this reviewed & merged? @seanmonstar
Just commenting to raise some noise/visibility for this PR.
It's a common feature for http clients. In Javascript the feature is available in axios and in Java you can find the feature in the SpringBoot RestTemplate as well as RestClient.
Thank you @thomasqueirozb !
Looking for this feature too. If you prefer not adding this feature, can you tell why? I'm cerious
Since this doesn't look like its going to be merged anytime soon you can use my fork like so:
reqwest = { git = "https://github.com/thomasqueirozb/reqwest", branch = "base_url" }
If you want to use cookies you'll have to use my own fork of reqwest_cookie_store too
reqwest = { git = "https://github.com/thomasqueirozb/reqwest", branch = "base_url", features = ["cookies"] }
reqwest_cookie_store = { git = "https://github.com/thomasqueirozb/reqwest_cookie_store" }
I periodically update the forks with the master branch of reqwest
Would also love to see this shipped. Great work @thomasqueirozb!
Hi, any updates on this feature?