Finish documenting the codebase.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
f14963a2c4
commit
780ab23310
31
README.md
31
README.md
|
@ -46,6 +46,9 @@ Afterward you can run using `mirror-server`
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
You can get all the options that `mirror-server` supports by running it with
|
||||||
|
the help option `--help` or `-h`:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ mirror-server --help
|
$ mirror-server --help
|
||||||
A simple server for mirror HTTP requests for testing.
|
A simple server for mirror HTTP requests for testing.
|
||||||
|
@ -58,3 +61,31 @@ Options:
|
||||||
-h, --help Print help
|
-h, --help Print help
|
||||||
-V, --version Print version
|
-V, --version Print version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
After starting the server, you can send requests to it. Using `curl` you
|
||||||
|
can send `mirror-server` JSON requests:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ curl -s -X PUT -D '{"hello": "world"}' -H 'Content-Type: application/json' \
|
||||||
|
http://localhost:8080/api/testing | jq .
|
||||||
|
```
|
||||||
|
|
||||||
|
And `mirror-server` responds to requests with JSON responses:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"method": "PUT",
|
||||||
|
"path": "/api/testing",
|
||||||
|
"host": "localhost:8180",
|
||||||
|
"headers": {
|
||||||
|
"accept": "*/*",
|
||||||
|
"content-length": "18",
|
||||||
|
"content-type": "application/json",
|
||||||
|
"host": "localhost:8080",
|
||||||
|
"user-agent": "curl/7.68.0"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"hello": "world"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
22
src/main.rs
22
src/main.rs
|
@ -51,24 +51,12 @@ struct EchoResponse {
|
||||||
///
|
///
|
||||||
/// ## Arguments
|
/// ## Arguments
|
||||||
/// * `method` - The HTTP [`Method`] used for the request. i.e. `GET`, `POST`, `PATCH`, etc.
|
/// * `method` - The HTTP [`Method`] used for the request. i.e. `GET`, `POST`, `PATCH`, etc.
|
||||||
/// TODO: Document the rest of the arguments
|
/// * `original_uri` - The URI used for the request.
|
||||||
|
/// * `host` - The hostname of the request.
|
||||||
|
/// * `header_map` - A map with the headers used during the request.
|
||||||
|
/// * `body` - An optional JSON body, if it is past in to the request.
|
||||||
|
/// Requires a header of `Content-Type: application/json` and a body passed in the request.
|
||||||
///
|
///
|
||||||
/// ## 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(
|
async fn echo_request(
|
||||||
method: Method,
|
method: Method,
|
||||||
original_uri: OriginalUri,
|
original_uri: OriginalUri,
|
||||||
|
|
Loading…
Reference in New Issue