diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index 6f9ab56..9840df9 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -10,6 +10,7 @@ pub fn get_routes() -> axum::Router { axum::Router::new() .route("/", get(index)) .nest_service("/static", ServeDir::new("static")) + .fallback(not_found) } #[derive(Template)] @@ -21,3 +22,13 @@ async fn index() -> impl IntoResponse { let html = template.render().unwrap(); (StatusCode::OK, Html(html).into_response()) } + +#[derive(Template)] +#[template(path = "404.html")] +struct NotFoundTemplate {} + +async fn not_found() -> impl IntoResponse { + let template = NotFoundTemplate {}; + let html = template.render().unwrap(); + (StatusCode::NOT_FOUND, Html(html).into_response()) +} diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..c2eaaff --- /dev/null +++ b/templates/404.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} {% block title %}Pagina non trovata{% endblock %} {% +block head %} + +{% endblock %} {% block content %} +

404 Pagina non trovata

+

La pagina che stai cercando non esiste.

+{% endblock %}