/hat-go

A CLI tool for HTTP API Testing

Primary LanguageGoOtherNOASSERTION

HAT

A CLI tool for HTTP API Testing

Build Status

Overview

HAT (HTTP API Testing) is a command line HTTP client. Its goal is to make HTTP API testing as easy as possible. It providers powerful ablitity to make HTTP request but with very simple arguments. HAT can be used for HTTP API testing, debugging and you can as well use it as CURL.

Install

Download

Untar and move

tar zxvf hat_*_0.7.0.tar.gz
sudo mv hat /usr/local/bin

Test it

hat --version

Documentation

hat [FLAGS] [METHOD] [URL] [OPTIONS]

Base usage

HAT is so powerful that it works without any arguments.

hat

=> This will make a GET request to http://127.0.0.1/.

FLAGS

FLAGS specify data type of POST and PUT

-j, --json  POST/PUT data as json encode (default)
-f, --form  POST/PUT data as form encode

FLAGS specify verbose

-v, --verbose

FLAGS specify show request/response time and download speed

-t

FLAGS specify request and response total timeout

--timeout=<int>

FLAGS specify show the version

-V, --version

FLAGS specify show the help

-h, --help

METHOD

METHOD specify http request method

GET         HTTP GET        GET / HTTP/1.1 (default)
POST        HTTP POST       POST / HTTP/1.1
PUT         HTTP PUT        PUT / HTTP/1.1
DELETE      HTTP DELETE     DELETE / HTTP/1.1

URL

URL is the HTTP URL for request, support http and https

<empty>     for http://127.0.0.1/ (default)
:8080       for http://127.0.0.1:8080/
:8080/api/  for http://127.0.0.1:8080/api/
/api/       for http://127.0.0.1/api/

OPTIONS

OPTIONS can specify the HTTP headers, HTTP body and HTTP URL query, add as many as you want

key:value   HTTP headers    for example User-Agent:HAT/0.1.0
key=value   HTTP body       for example name=likexian
key?=value  HTTP query      for example name?=likexian set URL to /?name=likexian

EXAMPLE

Just get a url

hat http://127.0.0.1/

Get a url and specify the query

hat http://127.0.0.1/ name?=likexian pass?=xxxxxxxx

=> This will make a GET request to http://127.0.0.1/?name=likexian&pass=xxxxxxxx

Get a url and specify the headers

hat http://127.0.0.1/ User-Agent:HAT/0.1.0 X-Forward-For:192.168.1.1

POST data to url (json)

hat post http://127.0.0.1/api/user name=likexian pass=xxxxxxxx

POST data to url (form)

hat -f post http://127.0.0.1/api/user name=likexian pass=xxxxxxxx

LICENSE

Copyright 2014, Kexian Li

Apache License, Version 2.0

About