From 7a510bc2ade72f82d98a380e81e8e66db55082e8 Mon Sep 17 00:00:00 2001 From: orhun Date: Thu, 26 Aug 2021 23:06:05 +0300 Subject: [PATCH] style(paste): use a custom 404 message while serving files --- src/server.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index 47dcb1f..32f068a 100644 --- a/src/server.rs +++ b/src/server.rs @@ -43,7 +43,8 @@ async fn serve( } match paste_type { PasteType::File | PasteType::Oneshot => { - let response = NamedFile::open(&path)? + let response = NamedFile::open(&path) + .map_err(|_| error::ErrorNotFound("file is not found or expired :("))? .disable_content_disposition() .set_content_type( mime::get_mime_type(&config.paste.mime_override, file.to_string())