mirror of
https://github.com/actix/actix-web.git
synced 2024-12-21 23:56:35 +00:00
check show_index
This commit is contained in:
parent
5abc46034a
commit
69f0c098e3
1 changed files with 7 additions and 3 deletions
|
@ -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() {
|
||||
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)?))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue