From 23774abc1b137b4067a5ddbdfb54b36a4452f63f Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 9 Feb 2023 10:55:49 +0100 Subject: [PATCH] better 404 page --- src/routes/not_found.rs | 13 ++++++++++++- templates/404.html | 42 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 templates/404.html diff --git a/src/routes/not_found.rs b/src/routes/not_found.rs index 462b8c7..bdd9f8a 100644 --- a/src/routes/not_found.rs +++ b/src/routes/not_found.rs @@ -1,5 +1,16 @@ use actix_web::{HttpResponse, Responder}; +use askama::Template; pub async fn page() -> impl Responder { - HttpResponse::NotFound().body("404 :/") + HttpResponse::NotFound().body(get_page()) +} + +#[derive(Template)] +#[template(path = "../templates/404.html")] +struct Error404Template {} + +pub fn get_page() -> std::string::String { + let index = Error404Template {}; + + index.render().unwrap() } diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..c5f5f8a --- /dev/null +++ b/templates/404.html @@ -0,0 +1,42 @@ + + + + Erreur 404 + + + + + + + + + + + + + + + + + + + + + +

404 :/

+ +