From bc01c3adbfc7ef0eb2492b7fdc521a4729ed2d15 Mon Sep 17 00:00:00 2001 From: Christopher Young Date: Thu, 31 Aug 2023 08:22:49 +0800 Subject: [PATCH] add index for `oapi-todos` example --- examples/oapi-todos/src/main.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/oapi-todos/src/main.rs b/examples/oapi-todos/src/main.rs index 666cf156a..216844705 100644 --- a/examples/oapi-todos/src/main.rs +++ b/examples/oapi-todos/src/main.rs @@ -10,7 +10,7 @@ static STORE: Lazy = Lazy::new(new_store); async fn main() { tracing_subscriber::fmt().init(); - let router = Router::new().push( + let router = Router::new().get(index).push( Router::with_path("api").push( Router::with_path("todos") .get(list_todos) @@ -31,6 +31,11 @@ async fn main() { Server::new(acceptor).serve(router).await; } +#[handler] +pub async fn index() -> Text<&'static str> { + Text::Html(INDEX_HTML) +} + /// List todos. #[endpoint( parameters( @@ -122,3 +127,18 @@ mod models { pub completed: bool, } } + +static INDEX_HTML: &str = r#" + + + Oapi todos + + + + + +"#;