A CLI for sending HTTP requests the easiest way possible.
Features:
- Simplified URL parsing, e.g.
:1234/path
becomeshttp://localhost:1234/path
- Configuration file in TOML
- URL aliases and interpolation
- Request history
- Starting a server on localhost (useful for development)
- And more
Use go get github.com/lunjon/http
.
To get started use http --help
.
Examples:
# POST http://localhost:1234/api/test
$ http post :1234/api/test --data '{"field":"value"}'
...
# GET https://api.example/resources/abbccc-122333, using header "Donald" with value "duck"
$ http get api.example/resources/abbccc-122333 --header "donald: duck"
...
Can be specified as:
- string:
http post http://example.com/api --data '{"name":"meow"}'
- file:
http post http://example.com/api --data-file r.json
- stdin:
http post http://example.com/api --data-stdin < myfile
The configuration file can be managed with:
http config
: list existing configuration filehttp config init
: creates a new if none exists at~/.config/httpcli/config.toml
http config edit
: edits the file using editor set in$EDITOR
environment variable
The configuration file can contain the following:
timeout = "5s" # A duration
fail = false # Always fail with an exit code != 0 if response status >= 400
# Aliases can be used for simplified URLs
[aliases]
local = "http://localhost:8080"
Aliases are a way of storing and simplifying URLs. For instance, in the example above we can send GET http://localhost:8080/path
using:
http get "{local}/path"
http
can start a local HTTP server that responds to any HTTP request:
http serve
This is useful for testing requests, since the server will basically echo any request it receives.
Can be generated by using http completion
.