Improve the documentation of the crate.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
aca5a57460
commit
762186ea2f
10
README.md
10
README.md
|
@ -14,7 +14,7 @@ working with REST API JSON calls, and catching headers.
|
|||
* Create a DEB package:
|
||||
* Install cargo-deb: `cargo install cargo-deb`
|
||||
* Create the DEB package: `cargo deb`
|
||||
* Faster builds using [cargo-watch](https://watchexec.github.io/#cargo-watch): `cargo watch -x run`
|
||||
* Faster builds using [`cargo-watch`](https://watchexec.github.io/#cargo-watch): `cargo watch -x run`
|
||||
* Installing the binary locally from source: `cargo install --path .`
|
||||
|
||||
## Install
|
||||
|
@ -27,8 +27,8 @@ the latest (or tagged) release.
|
|||
|
||||
Run via Docker using:
|
||||
|
||||
```bash
|
||||
docker run -p 8080:8080 code.birch-tree.net/dorian/mirror-server:latest
|
||||
```console
|
||||
$ docker run -p 8080:8080 code.birch-tree.net/dorian/mirror-server:latest
|
||||
```
|
||||
|
||||
### Debian Package
|
||||
|
@ -46,8 +46,8 @@ Afterward you can run using `mirror-server`
|
|||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
> mirror-server --help
|
||||
```console
|
||||
$ mirror-server --help
|
||||
A simple server for mirror HTTP requests for testing.
|
||||
|
||||
Usage: mirror-server [OPTIONS]
|
||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -13,7 +13,7 @@ use tower_http::trace;
|
|||
use tracing::{info, warn, Level};
|
||||
|
||||
|
||||
/// CLI arguments used by the [Parser].
|
||||
/// CLI arguments used by the [`Parser`].
|
||||
///
|
||||
/// Creates the usage and version information that is standard in a CLI
|
||||
/// utility.
|
||||
|
@ -32,7 +32,7 @@ struct CliArgs {
|
|||
/// The response consisting of the echoed request to the mirror-server.
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
struct EchoResponse {
|
||||
/// The [Method] used in the request.
|
||||
/// The [`Method`] used in the request.
|
||||
method: String,
|
||||
/// The path used in the request.
|
||||
path: String,
|
||||
|
@ -45,6 +45,15 @@ struct EchoResponse {
|
|||
body: Option<Value>,
|
||||
}
|
||||
|
||||
/// [`Handler`](axum::handler) for responding with a break-down of the captured request.
|
||||
///
|
||||
/// 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
|
||||
async fn echo_request(
|
||||
method: Method,
|
||||
original_uri: OriginalUri,
|
||||
|
@ -80,6 +89,10 @@ async fn echo_request(
|
|||
Json(response)
|
||||
}
|
||||
|
||||
/// Create a [`Router`] to handling capture all HTTP requests to the server.
|
||||
///
|
||||
/// Wires up a default catch-all route for the application. Also adds the tracing infrastructure
|
||||
/// to capture requests.
|
||||
fn app() -> Router {
|
||||
Router::new().fallback(echo_request).layer(
|
||||
trace::TraceLayer::new_for_http()
|
||||
|
@ -88,6 +101,7 @@ fn app() -> Router {
|
|||
)
|
||||
}
|
||||
|
||||
/// The main application starts the mirror-server application.
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let cli_args = CliArgs::parse();
|
||||
|
|
Loading…
Reference in New Issue