-
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 specifying default hostnames (instead of localhost) #838
Comments
FYI, I've worked around this for local scripting use by defining a function (in Fish, as that's the shell I use). I'm still working out the kinks, but here's the basic structure: function http
argparse --ignore-unknown 'base-url=' -- $argv # extract --base-url if specified as option
set opts (string match -rae '^-' -- $argv) # extract args that start with '-' into $opts
set rest (string match -raev '^-' -- $argv) # extract args that do not start with '-' into $rest
command http $opts (string join $flag_base_url $rest[1]) $rest[2..-1] # put $opts before $rest
end Note that this has meant that options that take an argument have to be joined with that argument with an equals sign instead of a space. So e.g. Instead, with this workaround, you've gotta do either |
Hmm, I just realized as I was posting #838 (comment) that this doesn't work when an http verb (get, post, put, etc.) is explicitly passed as the first argument, as this function statically prepends I think what I'll likely do is statically check if |
This has been open for a while. Will it be released soon? |
Draft PR remains open: #1377 I haven't had time nor motivation to push it to completion. However AFAIK it has not received any official confirmation that it would be accepted if it's cleaned up. So if a maintainer would be willing to confirm they'd be comfortable with this change before anybody puts more effort in that would be nice! |
This seems to be related to #215 and #180, but is not a pure duplicate:
I would like to be able to create an alias or shell function for accessing a certain rest API requiring authentication. I started with
but my main problem is that I cannot change the HTTP method (e.g. to PUT or PATCH) this way. I would like to be able to have a different way of specifying the default host, so that I do not have to add a commandline parsing around httpie. And I do have some hope, since httpie already supports a default hostname, only that it's hardcoded to be localhost.
I see two potential solutions:
~/.httpie/sessions/default/<name>.json
With both solutions, the above shell function could be turned into a simple alias passing the desired
--session
parameter.The text was updated successfully, but these errors were encountered: