httpi
A simple CLI tool written in Go for testing HTTP APIs. This project allows you to easily make GET and POST requests from the command line.
Features
- Make GET and POST requests
- Custom headers support
- JSON body support for POST requests
- Simple and intuitive command-line interface
Installation
# Clone the repository
git clone https://github.com/Soohyeuk/cli-api-tester.git
cd cli-api-tester
# Build and install the binary
go build -o $(go env GOPATH)/bin/httpi ./cmd
# Add to PATH (if not already added)
export PATH=$PATH:$(go env GOPATH)/bin
Usage
Basic syntax:
httpi <method> <url> [headers] [body]
Examples
- Simple GET request:
httpi GET https://api.example.com
- GET request with headers:
httpi GET https://api.example.com "Authorization: Bearer token,Content-Type: application/json"
- POST request with JSON body:
httpi POST https://api.example.com "Content-Type: application/json" '{"key": "value"}'
Testing with Local Server
The project includes a simple Flask server for testing. To use it:
- Start the Flask server:
python3 test/main.py
- Test with the CLI:
# GET request
httpi GET http://localhost:8080
# POST request
httpi POST http://localhost:8080/test "Content-Type: application/json" '{"message": "Hello"}'
Project Structure
.
├── cmd/
│ └── main.go # CLI entry point
├── internal/
│ └── client/
│ ├── client.go # HTTP client implementation
│ ├── config.go # Configuration management
│ └── request.go # Request handling
└── test/
└── main.py # Test server
Contributing
Feel free to submit issues and enhancement requests!