2024-05-10 17:51:54 -07:00
|
|
|
use crate::http_util::not_found_html_err;
|
2024-05-14 11:54:42 -07:00
|
|
|
use crate::http_util::not_found_html_handler;
|
2024-05-25 19:16:36 -07:00
|
|
|
use crate::model::app_state::AppStateInner;
|
2024-05-14 11:54:42 -07:00
|
|
|
use axum::http::StatusCode;
|
2024-05-10 17:51:54 -07:00
|
|
|
use axum::response::Html;
|
|
|
|
|
use axum::response::Response;
|
|
|
|
|
use html_escaper::Escape;
|
|
|
|
|
|
2024-05-25 19:16:36 -07:00
|
|
|
pub fn not_found_page(error_msg: Option<String>) -> Html<String> {
|
2024-05-10 17:51:54 -07:00
|
|
|
#[derive(boilerplate::Boilerplate)]
|
|
|
|
|
#[boilerplate(filename = "web/html/page/not_found.html")]
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
pub struct NotFoundHtmlPage {
|
|
|
|
|
error_msg: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let not_found_page = NotFoundHtmlPage {
|
|
|
|
|
error_msg: error_msg.unwrap_or_default(),
|
|
|
|
|
};
|
|
|
|
|
Html(not_found_page.to_string())
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-25 19:16:36 -07:00
|
|
|
pub fn not_found_html_response(_state: &AppStateInner, error_msg: Option<String>) -> Response {
|
|
|
|
|
not_found_html_err(not_found_page(error_msg))
|
2024-05-10 17:51:54 -07:00
|
|
|
}
|
2024-05-14 11:54:42 -07:00
|
|
|
|
2024-05-25 19:16:36 -07:00
|
|
|
#[axum::debug_handler]
|
|
|
|
|
pub async fn not_found_html_fallback() -> (StatusCode, Html<String>) {
|
|
|
|
|
not_found_html_handler(not_found_page(None))
|
2024-05-14 11:54:42 -07:00
|
|
|
}
|