use actix_web::{web, HttpRequest, HttpResponse, Responder}; use cached::proc_macro::once; use ramhorns::Content; use crate::{ config::Config, misc::utils::get_url, template::{Infos, NavBar}, }; pub async fn page(req: HttpRequest, config: web::Data) -> impl Responder { HttpResponse::NotFound().body(build_page( config.get_ref().to_owned(), get_url(req.connection_info()), )) } #[derive(Content, Debug)] struct NotFoundTemplate { navbar: NavBar, www: String, onion: Option, } #[once(time = 60)] fn build_page(config: Config, url: String) -> String { config.tmpl.render( "404.html", NotFoundTemplate { navbar: NavBar::default(), www: url, onion: config.fc.onion, }, Infos { page_desc: Some("Une page perdu du web".into()), ..Infos::default() }, ) }