go-http-cli

module
v0.8.1 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, Postman and httpie made with ❤ in Go.

Getting Started

Download the latest release for your platform.

Unzip it and put all three binaries in you path adding something like this to your ~/.bash_profile:

export PATH=$PATH:/path/to/extracted/root

There's also an auto-completion helper for bash. You can add the following to your ~/.bash_profile:

complete -f -C go-http-completion http

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.

Directories

Path Synopsis
binaries
go-http-daemon command
http command
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