Skip to content

Commit

Permalink
add index for oapi-todos example
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Aug 31, 2023
1 parent 416c591 commit bc01c3a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion examples/oapi-todos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static STORE: Lazy<Db> = 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)
Expand All @@ -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(
Expand Down Expand Up @@ -122,3 +127,18 @@ mod models {
pub completed: bool,
}
}

static INDEX_HTML: &str = r#"<!DOCTYPE html>
<html>
<head>
<title>Oapi todos</title>
</head>
<body>
<ul>
<li><a href="swagger-ui" target="_blank">swagger-ui</a></li>
<li><a href="rapidoc" target="_blank">rapidoc</a></li>
<li><a href="redoc" target="_blank">redoc</a></li>
</ul>
</body>
</html>
"#;

0 comments on commit bc01c3a

Please sign in to comment.