add docs for default file service

This commit is contained in:
ibraheemdev 2021-04-01 14:46:40 -04:00
parent 4697a772d2
commit 36ff76141f
1 changed files with 12 additions and 0 deletions

View File

@ -199,6 +199,18 @@ impl Files {
}
/// Sets default handler which is used when no matched file could be found.
///
/// For example, you could set a fall back static file handler:
/// ```rust
/// use actix_files::{Files, NamedFile};
///
/// # fn run() -> Result<(), actix_web::Error> {
/// let files = Files::new("/", "./static")
/// .index_file("index.html")
/// .default_handler(NamedFile::open("./static/404.html")?);
/// # Ok(())
/// # }
/// ```
pub fn default_handler<F, U>(mut self, f: F) -> Self
where
F: IntoServiceFactory<U, ServiceRequest>,