ducaale / xh

Friendly and fast tool for sending HTTP requests
MIT License
5.49k stars 96 forks source link

Proposal to add template requests #374

Closed apreifsteck closed 3 months ago

apreifsteck commented 3 months ago

Hello!

I know the xh project aims to have parity with httpie, but I was wondering if you would consider proposals for additional features beyond what httpie supports. For instance this feature proposal appeals to me, but hasn't been fully implemented yet. Is there room in xh for such a feature?

blyxxyz commented 3 months ago

I think it makes more sense to use shell scripts/functions for this. It's not ideal (because shell is a pretty weird language) but it gives you flexibility that would be a lot of work to implement inside xh (like including options, e.g. --follow or --session=mysession, or conditional logic).

For the base example in the linked issue you could write a shell function like this:

http_base() {
    route="$1"
    shift
    xh "https://httpbin.org/$route" sort=asc page=1 apikey=asdf "$@"
}

And then you can run http_base /post param1=x param2=y.

Other ideas:

apreifsteck commented 3 months ago

Tangentially related to both of your points, but while I was digging around trying to find something that would get me this I actually found slumber which does what I'm looking for. Oddly, it never came up in my googling, the only way I found it was on the ratatui app showcase page. So I can close this issue, but thank you for looking at this and giving it some thought. It certainly would be a big lift and I know it goes against the grain of the core tenant of parity with httpie as well.