diff --git a/examples/sample-response.json b/examples/sample-response.json new file mode 100644 index 0000000..a110a95 --- /dev/null +++ b/examples/sample-response.json @@ -0,0 +1,15 @@ +{ + "method": "PUT", + "path": "/api/testing", + "host": "localhost:8180", + "headers": { + "accept": "*/*", + "content-length": "18", + "content-type": "application/json", + "host": "localhost:8180", + "user-agent": "curl/7.68.0" + }, + "body": { + "hello": "world" + } +} diff --git a/src/main.rs b/src/main.rs index 180f10a..3c3a882 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,11 +49,26 @@ struct EchoResponse { /// /// Captures the request and responds with a JSON response of the elements of the request. /// -/// TODO: Add a example of the JSON output of the response. -/// /// ## Arguments /// * `method` - The HTTP [`Method`] used for the request. i.e. `GET`, `POST`, `PATCH`, etc. /// TODO: Document the rest of the arguments +/// +/// ## Example +/// +/// Sending a request using `curl`: +/// +/// ```console +/// $ curl -s -X PUT -D '{"hello": "world"}' -H 'Content-Type: application/json' \ +/// http://localhost:8080/api/testing | jq . +/// ``` +/// +/// Results in a JSON response: +/// +/// ```json +#[doc = include_str!("../examples/sample-response.json")] +/// ``` +/// + async fn echo_request( method: Method, original_uri: OriginalUri,