Return 404 on missing static file in todo example.

This commit is contained in:
Sergio Benitez 2017-04-12 02:58:45 -07:00
parent a2a0aab541
commit cf47daa8e1
1 changed files with 3 additions and 4 deletions

View File

@ -1,8 +1,7 @@
use rocket::response::NamedFile;
use std::io;
use std::path::{Path, PathBuf};
use rocket::response::NamedFile;
#[get("/<path..>", rank = 5)]
fn all(path: PathBuf) -> io::Result<NamedFile> {
NamedFile::open(Path::new("static/").join(path))
fn all(path: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("static/").join(path)).ok()
}