From ee4fa6eec58029d6a224771f579df4e9ec5d75bf Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 1 Apr 2024 06:01:02 +0000 Subject: docs(readme): add rossweisse usage example --- README.md | 43 ++++++++++++++++++++++++++++++++++--------- rossweisse/README.md | 4 +--- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7466075..f7ded2a 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,15 @@ out [Rossweisse](./rossweisse/) for more information! ### Features -| Feature | Description | -| - | - | -| `default` | Base Windmark framework using [Tokio](https://tokio.rs/) | -| `logger` | Enables the default [`pretty_env_logger`](https://github.com/seanmonstar/pretty-env-logger) integration | -| `auto-deduce-mime` | Exposes `Response`s and macros that automatically fill MIMEs for non-Gemini responses | -| `response-macros` | Simple macros for all `Response`s | -| `tokio` | Marks [Tokio](https://tokio.rs/) as the asynchronous runtime | -| `async-std` | Marks [`async-std`](https://async.rs/) as the asynchronous runtime | -| `prelude` | Exposes the `prelude` module containing the most used Windmark features | +| Feature | Description | +| ------------------ | ------------------------------------------------------------------------------------------------------- | +| `default` | Base Windmark framework using [Tokio](https://tokio.rs/) | +| `logger` | Enables the default [`pretty_env_logger`](https://github.com/seanmonstar/pretty-env-logger) integration | +| `auto-deduce-mime` | Exposes `Response`s and macros that automatically fill MIMEs for non-Gemini responses | +| `response-macros` | Simple macros for all `Response`s | +| `tokio` | Marks [Tokio](https://tokio.rs/) as the asynchronous runtime | +| `async-std` | Marks [`async-std`](https://async.rs/) as the asynchronous runtime | +| `prelude` | Exposes the `prelude` module containing the most used Windmark features | ### Add Windmark and Tokio as Dependencies @@ -52,6 +52,8 @@ tokio = { version = "1.26.0", features = ["full"] } ```rust // src/main.rs +// ... + #[windmark::main] async fn main() -> Result<(), Box> { windmark::router::Router::new() @@ -66,6 +68,29 @@ async fn main() -> Result<(), Box> { } ``` +### Implement a Windmark server using Rossweisse + +```rust +// src/main.rs + +// ... + +#[rossweisse::router] +struct Router; + +#[rossweisse::router] +impl Router { + #[route(index)] + pub fn index( + _context: windmark::context::RouteContext, + ) -> Response { + Response::success("Hello, World!") + } +} + +// ... +``` + ## Examples Examples can be found within the diff --git a/rossweisse/README.md b/rossweisse/README.md index 23af367..e238eea 100644 --- a/rossweisse/README.md +++ b/rossweisse/README.md @@ -13,9 +13,7 @@ use rossweisse::route; use windmark::response::Response; #[rossweisse::router] -struct Router { - _phantom: (), -} +struct Router; #[rossweisse::router] impl Router { -- cgit v1.2.3