style(paste): use a custom 404 message while serving files

This commit is contained in:
orhun 2021-08-26 23:06:05 +03:00
parent 73359f3534
commit 7a510bc2ad
No known key found for this signature in database
GPG key ID: F83424824B3E4B90

View file

@ -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())