go-http-cli

module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2018 License: MIT

README

go-http-cli

Build Status Go Report Card

An HTTP client inspired by curl and httpie made in Go.

Profiles

IMPORTANT! Please don't store your passwords on plain text files! Use this only for local/development environments.

go-http-cli can use profile files, which are just configuration files in a special location. The location by default points to ${user.home}/go-http-cli but it can be configured through the environment variable GO_HTTP_PROFILES.

To activate a profile just add +profileName as part of your arguments. In this case, it would look for a ${user.home}/go-http-cli/profileName.{yml|yaml} file. It will fail if it can't find it.

An example would be to setup a yaml file like the following:

baseURL:
  https://family-menu.herokuapp.com/api/v1
headers:
  Content-type:
    - application/json
  Authorization:
    - Bearer ${your-token-here}
variables:
  companyId: 123456

And then you can just call the api like the following:

$ http +my-profile '{companyId}/people'

GET https://family-menu.herokuapp.com/api/v1/123456/people
Content-Type: application/json
Authorization: Bearer your-token-here

The path can be a relative path or an absolute path. The algorithm is very simple, it just concatenates baseURL with URL making sure only one / will exist between the two. It will also use the variables set in the configuration file to replace the ones in the URL.

Examples

Example command pointing to a test server:

http \
  -H Content-Type=application/json \
  -X POST \
  -d "Some test data" \
  http://localhost:3000/test

Output:

Running the Build

This project uses Gradle as the build system. To run it, the only thing you'll need is to have Java installed. Then, just run ./gradlew build and everything should happen. This command should execute all checks, tests and install all binaries.

Bash completion

There's a go-http-completion command that can be used for completion using tabs in bash. For now it only supports profile names. To install it, just run (or add to your ~/.bash_profile):

complete -f -C go-http-completion http

Directories

Path Synopsis
binaries
Package request contains all the things used to create requests.
Package request contains all the things used to create requests.

Jump to

Keyboard shortcuts

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