Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Rex

Rex is a simple, command-line HTTP client written in Go. It allows you to make HTTP requests with custom headers, query parameters, and JSON payloads directly from your terminal.

Installation

Ensure you have Go installed.

git clone https://github.com/CharanMunur/Rex.git
cd Rex
go build -o rex

(Alternatively, you can install it using go install if you want it available in your PATH).

Usage

rex METHOD URL [--form] [ARGUMENTS...]

Flags

  • --form: Sends the request body as URL-encoded form data (application/x-www-form-urlencoded) instead of the default JSON format.

Arguments Syntax

Rex uses a simple syntax to differentiate between headers, query parameters, and JSON body fields:

  • Headers: Key:Value (e.g., Authorization:"Bearer token")
  • Query Parameters: Key==Value (e.g., page==2)
  • JSON Body Fields: Key=Value (e.g., name=John)
  • Raw JSON Body Fields: Key:=Value (e.g., done:=false, count:=10) - Sent as their actual JSON types (boolean, number, array) rather than strings.

Examples

Basic GET Request:

rex GET https://jsonplaceholder.typicode.com/todos/1

GET Request with Query Parameters and Headers:

rex GET https://api.example.com/data Authorization:"Bearer my_token" status==active

(This sends a GET request to https://api.example.com/data?status=active with the specified Authorization header.)

POST Request with JSON Body:

rex POST https://api.example.com/users name=John age=30 Content-Type:application/json

(This sends a POST request with the JSON body {"name":"John","age":"30"}.)

POST Request with Raw JSON Types:

rex POST https://api.example.com/tasks title="Buy groceries" done:=false priority:=1

(This sends a POST request with the JSON body {"title":"Buy groceries","done":false,"priority":1}.)

POST Request with URL-encoded Form Data:

rex POST https://api.example.com/login --form username=admin password=secret

(This sends a POST request with the body username=admin&password=secret and the Content-Type: application/x-www-form-urlencoded header.)

Output

Rex automatically formats and pretty-prints JSON responses. If the response is not valid JSON, it falls back to printing the raw body along with the HTTP status code.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages