http

command module
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 4 Imported by: 0

README

http

A CLI for sending HTTP requests the easiest way possible.

Features:

  • Simplified URL parsing, e.g. :1234/path becomes http://localhost:1234/path
  • Configuration file in TOML
  • URL aliases and interpolation
  • Request history
  • Starting a server on localhost (useful for development)
  • And more

Installation

Use go get github.com/lunjon/http.

Usage

To get started use http --help.

Sending requests

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"
...
Request body

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

Configuration file

The configuration file can be managed with:

  • http config: list existing configuration file
  • http 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"

Shell completion

Shell completion can be generated by using http completion.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cli
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL