diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 2 | ||||
| -rw-r--r-- | src/routes/mod.rs | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 59ffb24..4f548d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ mod pagination; mod routes; use axum::{ + handler::Handler, http::{header, Request}, Router, }; @@ -43,6 +44,7 @@ async fn create_app() -> Router { Router::new() // Map all routes to `/v1/*` namespace .nest("/v1", api_routes) + .fallback(crate::routes::page_404.into_service()) // Mark the `Authorization` request header as sensitive so it doesn't // show in logs. .layer(SetSensitiveHeadersLayer::new(std::iter::once( diff --git a/src/routes/mod.rs b/src/routes/mod.rs index 7e61662..0de7291 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,3 +1,10 @@ pub mod auth; pub mod model; pub mod user; + +use crate::errors::AppError; +use axum::response::IntoResponse; + +pub async fn page_404() -> impl IntoResponse { + AppError::NotFound("Route not found".to_string()) +} |
