-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Allow setting of default base_url #215
Comments
I've been looking for something like this, but instead of working with a single environment, I have multiple that I can hit. As such, I'd like to do something like this:
I know this isn't necessarily the role of HTTPie, but it's a feature that otherwise I'd otherwise write a wrapper for. If anything, the ability to write a plugin to support this would be helpful. |
Related feature request: #180 |
@jakubroztocil IMHO there is a difference between issue #180 or @smartboyathome suggestion and my proposal. Sessions solve the problem of defining default parameters (headers, query string etc) which is a very nice feature, indeed. But as far as I know it does not solve the default base url problem. I still think it would be nice to be able to define a default base url for the above mentioned reasons. Instead of writing a wrapper around HTTPie (which works perfectly fine) I like to see how people think about including it as a feature in HTTPie. I am not sure if it should be the responsibility of HTTPie to offer such as feature. |
@nrocco You are right, it's not actually related. If this should be added, then I think it should be done by redefining/extending the similar and already existing Something like this:
So that: $ http /foo # => http://localhost/foo
$ export HTTPIE_BASEURL=http://example.org
$ http /foo # => http://example.org/foo The localhost shortcut also enables a port to be specified (e.g. |
@jakubroztocil Thanks for your feedback. Allow me to prepare a PR and report back here. If you agree with the implementation then fine, otherwise it can serve as a basis for a better implementation or at least for the discussion if it should be part of HTTPie or not. |
@jakubroztocil I have prepared a pull request #217. I am looking forward to your thoughts. |
Have a look at https://github.com/eliangcs/http-prompt if you're interested in this feature. |
@jakubroztocil I would vote for this feature, using http-prompt is not always convenient |
+1 This would be helpful! |
+1 Must have this! |
Please can someone comment on #838 ? I feel like the existing session functionality could be a good match for adding a default host (instead of localhost). |
Hi there, first of all
httpie
is an excellent library. I recently switched to it after usingresty
for ages.One of the nice features i am missing is a way to set a base url that will be used for subsequent
http
invocations.I often find myself issuing multiple rest calls when testing/browsing an API and defining a base url saves me from a lot of typing.
For example, assume the following base url:
When issuing the following command
Will do a GET request to the resource located at
https://api.example.com/api/v1/users
.Currently I solve my impediment by applying the following patch to the
httpie
libraryThis allows me to define a base url for the current running shell:
I am curious what you think about this approach and maybe have a better idea.
I would be happy to contribute to this idea if needed.
Keep up the great work.
The text was updated successfully, but these errors were encountered: