This Rust project provides a simple yet powerful tool for making HTTP requests and handling responses. Built with reqwest
for performing HTTP requests, tokio
for asynchronous runtime, and serde_json
for JSON parsing, it offers functionalities to make GET, POST, PUT, and PATCH requests, manage request headers and body, and pretty-print JSON responses.
- Support for various HTTP methods: GET, POST, PUT, PATCH.
- JSON body and headers configuration via external files.
- Pretty-printing JSON responses directly within the application.
- Configuration through a
config.json
file for default values. - Synchronous reading of user inputs and asynchronous request handling.
- Rust programming language
- Cargo package manager
- Clone the repository to your local machine:
git clone https://github.com/Kythonlk/rust-api-client.git
cd rust-api-client
- Build the project:
cargo build
- Run the project:
cargo run
After running the application, follow the on-screen prompts to:
- Enter the URL or leave blank to use the URL from
config.json
. - Select the request type (GET, POST, PUT, PATCH).
- If applicable, specify the path to the JSON body file for POST, PUT, or PATCH requests.
- Decide whether to add headers from a file and specify the path to the JSON headers file if yes.
- View the pretty-printed JSON response or raw response text in the console.
config.json
: Set default values for the URL and any other configurations you might need.- JSON files for request bodies and headers: Format according to the requirements of your API endpoint.
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs, feature requests, or improvements.