add 404 page

This commit is contained in:
neri 2020-08-19 16:24:42 +02:00
parent 458220df47
commit c9d00db39a
1 changed files with 7 additions and 0 deletions

View File

@ -141,6 +141,12 @@ async fn download(
}
}
async fn not_found() -> Result<HttpResponse, Error> {
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)?