From c9d00db39af8c389dee5bc758b66d82ec8fb60e3 Mon Sep 17 00:00:00 2001 From: neri Date: Wed, 19 Aug 2020 16:24:42 +0200 Subject: [PATCH] add 404 page --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.rs b/src/main.rs index 2b9e70a..4de483e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -141,6 +141,12 @@ async fn download( } } +async fn not_found() -> Result { + Ok(HttpResponse::NotFound() + .content_type("text/plain") + .body("not found")) +} + fn get_db_url() -> String { if let Ok(database_url) = env::var("DATABASE_URL") { return database_url; @@ -239,6 +245,7 @@ async fn main() -> std::io::Result<()> { .route(web::get().to(download)), ) .service(Files::new("/static", "static").disable_content_disposition()) + .default_service(web::route().to(not_found)) } }) .bind(bind_address)?