1 2 3 4 5 6 7 8 9 10 11 12 13 14
//! どのルートにも当たらなかったときの HTML。
//! 使う側が自分の 404 を出すなら、`route::build` に渡すルータで `fallback` を上書きする。
use axum::http::StatusCode;
use axum::response::{Html, IntoResponse, Response};
use crate::html;
/// どのルートにも当たらなかったとき。ページなので HTML で返す
pub async fn not_found() -> Response {
let body = r#"<h1>404</h1><p class="note">このページはありません。</p>"#;
let document = html::document("見つかりません", body);
(StatusCode::NOT_FOUND, Html(document)).into_response()
}