diff --git a/src/errors/not_found.rs b/src/errors/not_found.rs index 9ccf9d1..fbfc592 100644 --- a/src/errors/not_found.rs +++ b/src/errors/not_found.rs @@ -1,29 +1,33 @@ use std::array; -use maud::{ - html, - Markup, +use axum::{ + http::StatusCode, + response::IntoResponse, }; +use maud::html; use crate::{ asset, page::cube, }; -pub async fn handler() -> Markup { - cube::create( - Some("404"), - asset::Css::Shared("cube-grid.css"), - array::from_fn(|_| { - html! { - .frame { - a href="/" { "404" } +pub async fn handler() -> impl IntoResponse { + ( + StatusCode::NOT_FOUND, + cube::create( + Some("404"), + asset::Css::Shared("cube-grid.css"), + array::from_fn(|_| { + html! { + .frame { + a href="/" { "404" } + } + .square .black {} + .square .magenta {} + .square .magenta {} + .square .black {} } - .square .black {} - .square .magenta {} - .square .magenta {} - .square .black {} - } - }), + }), + ), ) } diff --git a/src/routes/blog.rs b/src/routes/blog.rs index 845c9c3..0526ed4 100644 --- a/src/routes/blog.rs +++ b/src/routes/blog.rs @@ -1,6 +1,11 @@ use std::sync::LazyLock; -use axum::extract::Path; +use axum::{ + body::Body, + extract::Path, + http::Response, + response::IntoResponse, +}; use indexmap::IndexMap; use itertools::Itertools; use maud::{ @@ -70,10 +75,10 @@ pub async fn index_handler() -> Markup { ) } -pub async fn entry_handler(Path(entry): Path) -> Markup { +pub async fn entry_handler(Path(entry): Path) -> Response { if let Some((metadata, body)) = ENTRIES.get(entry.as_str()) { - text::create(Some(&metadata.title), Page::Other, body) + text::create(Some(&metadata.title), Page::Other, body).into_response() } else { - not_found::handler().await + not_found::handler().await.into_response() } }