handlers.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::errors::{ Result }; use crate::state::{ ApplicationState }; use crate::templates; use axum::extract::{ State }; use axum::http::{ StatusCode }; use axum::response::{ Html, IntoResponse }; use std::sync::{ Arc }; pub(crate) async fn index_handler(State(state): State<Arc<ApplicationState>>) -> Result<Html<String>> { let context = templates::index_context(&state)?; let html = state.tera.render("markdown_page.tera.html", &context)?; Ok(Html(html)) } pub(crate) async fn not_found_handler() -> impl IntoResponse { (StatusCode::NOT_FOUND, "Not found") }