This commit is contained in:
Ali MJ Al-Nasrawy 2021-06-23 21:22:52 +03:00
parent 7e60a5bb2e
commit 0f5e08d477
1 changed files with 6 additions and 3 deletions

View File

@ -168,16 +168,19 @@ impl Files {
///
/// When a path doesn't pass the filter, [`Files::default_handler`] is called if set, otherwise,
/// `404 Not Found` is returned.
///
/// # Examples
/// ```
/// use std::path::Path;
/// use actix_files::Files;
///
/// // prevent searching subdirectories and following symlinks
/// let files_service = Files::new("/", "./static").path_filter(|path, _| {
/// path.components.count() == 1
/// path.components().count() == 1
/// && Path::new("./static")
/// .join(path)
/// .symlink_metadata()
/// .map(|m| m.file_type().is_symlink())
/// .map(|m| !m.file_type().is_symlink())
/// .unwrap_or(false)
/// });
/// ```