From 7e60a5bb2e285a86043bcc03b0d26b8c894d6ab0 Mon Sep 17 00:00:00 2001 From: Ali MJ Al-Nasrawy Date: Wed, 23 Jun 2021 01:24:28 +0300 Subject: [PATCH] more docs --- actix-files/src/files.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/actix-files/src/files.rs b/actix-files/src/files.rs index b1405d0d4..e04d1e134 100644 --- a/actix-files/src/files.rs +++ b/actix-files/src/files.rs @@ -162,8 +162,25 @@ impl Files { /// Sets path filtering closure. /// - /// When a path doen't pass the filter, [`Files::default_handler`] is called if set, otherwise, + /// The path provided to the closure is relative to `serve_from` path. + /// You can safely join this path with the `serve_from` path to get the real path. + /// However, the real path may not exist since the filter is called before checking path existence. + /// + /// When a path doesn't pass the filter, [`Files::default_handler`] is called if set, otherwise, /// `404 NotFound` is returned. + /// ``` + /// use std::path::Path; + /// use actix_files::Files; + /// + /// let files_service = Files::new("/", "./static").path_filter(|path, _| { + /// path.components.count() == 1 + /// && Path::new("./static") + /// .join(path) + /// .symlink_metadata() + /// .map(|m| m.file_type().is_symlink()) + /// .unwrap_or(false) + /// }); + /// ``` pub fn path_filter(mut self, f: F) -> Self where F: Fn(&Path, &RequestHead) -> bool + 'static,