|
| 1 | +# echo-rs |
| 2 | + |
| 3 | +[](https://crates.io/crates/echo-rs) |
| 4 | +[](https://docs.rs/echo-rs) |
| 5 | +<!-- [](https://github.com/the-wondersmith/echo-rs/actions) --> |
| 6 | +<!-- [](https://coveralls.io/github/the-wondersmith/echo-rs?branch=main) --> |
| 7 | + |
| 8 | +`echo-rs` provides a dead-simple HTTP echo server - i.e. it simply |
| 9 | +parrots back any request it receives in a developer-friendly JSON-serialized |
| 10 | +format. |
| 11 | + |
| 12 | +It aims to provide a simple and convenient utility to assist in designing |
| 13 | +new applications, developing / testing API clients, or as a "dummy" workload |
| 14 | +for use in scaffolding new Kubernetes / cloud-native services. |
| 15 | + |
| 16 | +### License |
| 17 | + |
| 18 | +[`AGPL-3.0-or-later`](https://spdx.org/licenses/AGPL-3.0-or-later.html) |
| 19 | + |
| 20 | + |
| 21 | +### Features |
| 22 | +`echo-rs` provides: |
| 23 | + |
| 24 | +- A simple HTTP echo server, returning a JSON-serialized representation of any request made to it |
| 25 | +- Prometheus metrics (helpful when using `echo-rs` as a dummy workload when designing new Kubernetes services) |
| 26 | + |
| 27 | + |
| 28 | +### Basic Usage |
| 29 | + |
| 30 | +Run the server locally - |
| 31 | + |
| 32 | +```bash |
| 33 | +docker run -it -p 8080:8080 --rm docker.io/thewondersmith/echo-rs:latest --metrics=false --log-level=debug |
| 34 | +``` |
| 35 | + |
| 36 | +Then make a request to it with any HTTP client - |
| 37 | + |
| 38 | +```bash |
| 39 | +curl -X POST \ |
| 40 | + "http://localhost:8080/some/super-cool/endpoint?param1=some-param-value¶m2=another-param-value" \ |
| 41 | + -H 'Content-Type: application/json' \ |
| 42 | + -H 'App-Specific-Header: app_specific_value' \ |
| 43 | + -d '{"target": "echo-rs", "expected": "response", "some": ["more", "none", null], "nested": {"turtles": {"all": {"the": {"way": "down"}}}}}' |
| 44 | +``` |
| 45 | + |
| 46 | +`echo-rs` should return the JSON-serialized representation of the request - |
| 47 | + |
| 48 | +```json |
| 49 | +{ |
| 50 | + "method": "POST", |
| 51 | + "path": "/some/super-cool/endpoint", |
| 52 | + "headers": { |
| 53 | + "user-agent": "curl/7.87.0", |
| 54 | + "host": "localhost:8080", |
| 55 | + "accept": "*/*", |
| 56 | + "content-type": "application/json", |
| 57 | + "app-specific-header": "app_specific_value", |
| 58 | + "content-length": "135" |
| 59 | + }, |
| 60 | + "params": { |
| 61 | + "param1": "some-param-value", |
| 62 | + "param2": "another-param-value" |
| 63 | + }, |
| 64 | + "body": { |
| 65 | + "expected": "response", |
| 66 | + "nested": { |
| 67 | + "turtles": { |
| 68 | + "all": { |
| 69 | + "the": { |
| 70 | + "way": "down" |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + }, |
| 75 | + "some": [ |
| 76 | + "more", |
| 77 | + "none", |
| 78 | + null |
| 79 | + ], |
| 80 | + "target": "echo-rs" |
| 81 | + } |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +### TODO: |
| 86 | +- Tests 😅 |
0 commit comments