Skip to content

Allow specifying default hostnames (instead of localhost) #838

@hmeine

Description

@hmeine

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

function girder {
    https --session=~/.girder_session.json girder.host.local.lan/api/v1/$1 ${@:2}
}

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:

  1. Allow setting of default base_url #215 contains a small change introducing an environment variable for the default host, which would solve my issue.
  2. Another idea I had (more in the line of Custom User-Agent not remembered during session #180) would be to make the default hostname an optional part of the sessions. Maybe that could even be made to work with named sessions, by looking into a "default" host directory: ~/.httpie/sessions/default/<name>.json

With both solutions, the above shell function could be turned into a simple alias passing the desired --session parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs 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