httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
32.67k stars 3.68k forks source link

Default headers by domain #1537

Open ohshazbot opened 8 months ago

ohshazbot commented 8 months ago

Checklist


Enhancement request

I would like the ability to configure a default set of headers to use on a per domain basis, such that if I make a request against a domain, the headers per my configuration get included without me having to adjust the CLI command …


Problem it solves

I'm working on a project where we are currently playing with a few different domains. I have a different set of credentials for the different domains, so whenever I am exercising an API, I have to muck around with both the domain URL as well as the headers I'm including. I would love to streamline the amount of things I have to muck with to change the target of my request and I think the best way to do this would be the ability to specify headers on a per-domain basis in my config file.

I am open to alternatives, but for me it boils down to trying to widdle down modifying a domain + header to modifying a single value for me to retarget a request (including updating the credentials I shouldbe using)


Additional information, screenshots, or code examples

Currently requests look like this http get http://0.0.0.0:6543/staging/7 "x-ob-api: $LOCAL_API_KEY" and http get https://devapi.domain.com/staging/618 "x-ob-api: $DEV_API_KEY" and I would like to be able to so something as straightforward as http get http://0.0.0.0:6543/staging/7 (with appropriate configuration). If there's a desire for something more encompassing or to get away from concerns with domain parsing (I don't think there is, but just in case) something like http get --domain dev /rest/of/path could be an option, but I think the rest of the url starts to get a bit weird there, but could be just me. …

aroraprince commented 3 weeks ago

Looks like 1568 might share the same solution. We should be able to provide a static set of headers in the config to be used per site.