Skip to content

per-directory config file (.httpierc) #1229

Description

@kykungz

Checklist

  • I've searched for similar feature requests.

Enhancement request

It would be great to have a per-directory httpie config file such as .httpierc (same naming convention with .prettierrc, .eslintrc or .npmrc).


Problem it solves

The httpie config seems to act as a "global" config on all http or https command, which sometimes polluted the request that we are trying to make.

For example, I don't want to add the same api-key header on every requests I make, and by adding this header, some API calls might fail because they don't accept this same header.

The .httpierc idea seemed to be opened before at #953 but was closed in favor of the global ~/.config/httpie/config.json config file. However, the per-directory use case was not yet been solved.

This per-directory config file could also (indirectly) solve the problem of Config by host #809 too, but the reason that I want to go for directory-based config file is because it will not pollute localhost calls. For example, if I have multiple projects that are using http://localhost:5000, I won't have a way to distinguish them if I use the "Config by host" option.

I understand that we can use the HTTPIE_CONFIG_DIR to change the config directory to the local one, but having to explicitly set an env variable on every shell opened seems to be cumbersome and not friendly when working in teams.


Additional information, screenshots, or code examples

I think this could be achievable by adding a new step at get_default_config_dir to look for .httpierc on the current working directory (or by recursively looking for .httpierc on any top-level directory).

https://github.com/httpie/httpie/blob/df58ec683e4f574507ea944d95ed1749941aee95/httpie/config.py#L34-L45

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or enhancementneeds product designWe like the idea, but we want to explore the problem deeper, and consider the solution holistically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions