Axum HttpBin is a project aiming to implement functionality similar to httpbin.org using the Axum web framework in Rust. It provides a collection of HTTP endpoints useful for testing and debugging HTTP clients.
To start the server locally, clone this repository and run:
$ cargo run
This will start the Axum HttpBin server on http://localhost:3000
.
All endpoints return JSON responses, the exact structure of which varies based on the specific request.
So far, Axum HttpBin implements the following HTTP endpoints:
Method | Endpoint | Description | Status |
---|---|---|---|
GET | /get |
Returns the request data as JSON. | ✅ |
PUT | /put |
Returns the request data as JSON. | ✅ |
POST | /post |
Returns the request data as JSON. | ✅ |
PATCH | /patch |
Returns the request data as JSON. | ✅ |
DELETE | /delete |
Returns the request data as JSON. | ✅ |
POST | /post/json |
Returns the JSON data from the request. | ✅ |
POST | /post/form |
Returns the form data from the request. | ✅ |
POST | /post/file |
Returns the file data from the request. | ✅ |
GET | /basic-auth/user/passwd |
Performs authorization using 'Basic' HTTP Authentication | ✅ |
GET | /bearer |
Performs authorization using 'Bearer' HTTP Authentication | ✅ |
The JSON responses contain, at a minimum, the basic request data:
Request:
POST "localhost:3000/post"
Response:
{
"args": {},
"headers": {
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"connection": "keep-alive",
"content-length": "0",
"host": "localhost:3000",
"user-agent": "HTTPie/3.2.2"
},
"method": "POST",
"origin": "127.0.0.1",
"url": "/post"
}
If you'd prefer not to have rustc
or cargo
installed on your system, you can
leverage Flox to run this server.
Flox is a virtual environment and package manager. To use it, install Flox. Then, from the root of this project, run:
$ flox activate
This will activate a virtual environment in which rustc
and cargo
are installed.
Once activated, you can run the server with:
$ cargo run
This project is licensed under the MIT License - see the LICENSE file for details.