Add a sample curl and JSON response to the API.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Dorian 2024-02-24 10:04:22 -05:00
parent 762186ea2f
commit f14963a2c4
2 changed files with 32 additions and 2 deletions

View File

@ -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"
}
}

View File

@ -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,