mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-28 01:52:57 +01:00
check show_index
This commit is contained in:
parent
5abc46034a
commit
69f0c098e3
@ -205,7 +205,7 @@ impl FromRequest for FilesystemElement {
|
|||||||
pub struct StaticFiles {
|
pub struct StaticFiles {
|
||||||
directory: PathBuf,
|
directory: PathBuf,
|
||||||
accessible: bool,
|
accessible: bool,
|
||||||
_show_index: bool,
|
show_index: bool,
|
||||||
_chunk_size: usize,
|
_chunk_size: usize,
|
||||||
_follow_symlinks: bool,
|
_follow_symlinks: bool,
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ impl StaticFiles {
|
|||||||
StaticFiles {
|
StaticFiles {
|
||||||
directory: dir,
|
directory: dir,
|
||||||
accessible: access,
|
accessible: access,
|
||||||
_show_index: index,
|
show_index: index,
|
||||||
_chunk_size: 0,
|
_chunk_size: 0,
|
||||||
_follow_symlinks: false,
|
_follow_symlinks: false,
|
||||||
}
|
}
|
||||||
@ -259,7 +259,11 @@ impl<S> Handler<S> for StaticFiles {
|
|||||||
let path = self.directory.join(&relpath).canonicalize()?;
|
let path = self.directory.join(&relpath).canonicalize()?;
|
||||||
|
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
|
if self.show_index {
|
||||||
Ok(FilesystemElement::Directory(Directory::new(self.directory.clone(), path)))
|
Ok(FilesystemElement::Directory(Directory::new(self.directory.clone(), path)))
|
||||||
|
} else {
|
||||||
|
Err(io::Error::new(io::ErrorKind::NotFound, "not found"))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(FilesystemElement::File(NamedFile::open(path)?))
|
Ok(FilesystemElement::File(NamedFile::open(path)?))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user