8 releases (stable)
3.0.0 | Feb 11, 2025 |
---|---|
2.0.0 | Jan 24, 2022 |
1.2.1 | Jan 14, 2022 |
1.2.0 | Nov 24, 2021 |
0.1.0 | Jun 6, 2021 |
#144 in HTTP server
104 downloads per month
9KB
93 lines
Echo server
HTTP echo server, that's it.
Installation
cargo install echo-server
Usage
Defaults:
- HTTP server listens to
0.0.0.0:8080
. - HTTP request headers return with the response.
- GET requests have no body content.
echo-server [-p|--port=8080]
All HTTP verbs are supported.
Configuration options
Set static response body.
echo server [-b|--body="Custom GET response body"]
Set (repeated) static response headers key:value
pairs.
echo server [-h|--header="key1:value1"] [-h|--header="key2:value2"]
GET
request
curl -vvv -X GET localhost:8080
curl -vvv -X GET -H "x-random-header: test" localhost:8080
POST
request
curl -vvv -X POST -H "Content-Type: application/json" -d '{"hello": "world"}' localhost:8080
Docker
You can run a precompiled image from Docker hub:
docker run --rm -p 8080:8080 --name echo swaagie/echo-server:latest
Or build the image local:
docker build -t echo-server .
docker run --rm -p 8080:8080 --name echo echo-server
Listen on a different port:
docker run --rm -p 8081:8081 --name echo echo-server --port=8081
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Dependencies
~8–14MB
~174K SLoC