1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-21 15:46:48 +00:00

check show_index

This commit is contained in:
Nikolay Kim 2017-12-03 16:58:31 -08:00
parent 5abc46034a
commit 69f0c098e3

View file

@ -205,7 +205,7 @@ impl FromRequest for FilesystemElement {
pub struct StaticFiles {
directory: PathBuf,
accessible: bool,
_show_index: bool,
show_index: bool,
_chunk_size: usize,
_follow_symlinks: bool,
}
@ -237,7 +237,7 @@ impl StaticFiles {
StaticFiles {
directory: dir,
accessible: access,
_show_index: index,
show_index: index,
_chunk_size: 0,
_follow_symlinks: false,
}
@ -259,7 +259,11 @@ impl<S> Handler<S> for StaticFiles {
let path = self.directory.join(&relpath).canonicalize()?;
if path.is_dir() {
Ok(FilesystemElement::Directory(Directory::new(self.directory.clone(), path)))
if self.show_index {
Ok(FilesystemElement::Directory(Directory::new(self.directory.clone(), path)))
} else {
Err(io::Error::new(io::ErrorKind::NotFound, "not found"))
}
} else {
Ok(FilesystemElement::File(NamedFile::open(path)?))
}