From 36ff76141fbf6e307e19921fbedcda656c8bb6c0 Mon Sep 17 00:00:00 2001 From: ibraheemdev Date: Thu, 1 Apr 2021 14:46:40 -0400 Subject: [PATCH] add docs for default file service --- actix-files/src/files.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/actix-files/src/files.rs b/actix-files/src/files.rs index ff4241340..9b24c4b21 100644 --- a/actix-files/src/files.rs +++ b/actix-files/src/files.rs @@ -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(mut self, f: F) -> Self where F: IntoServiceFactory,