From b1fb44722a61ed4b14c4ccc1d99350c176fa0f53 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 14 Feb 2026 20:52:04 +0900 Subject: [PATCH] docs(files): improve `index_file` docs (#3924) --- actix-files/src/files.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/actix-files/src/files.rs b/actix-files/src/files.rs index 7440a43e7..1c7a1d902 100644 --- a/actix-files/src/files.rs +++ b/actix-files/src/files.rs @@ -213,10 +213,14 @@ impl Files { self } - /// Set index file + /// Sets index file for directory requests. /// - /// Shows specific index file for directories instead of - /// showing files listing. + /// When a directory is requested, this value is appended to the directory's path on disk. + /// Therefore, the index file path is relative to the served directory (the `serve_from` path + /// passed to [`Files::new`]) and should not include the `serve_from` prefix. + /// + /// For example, to serve `./static/index.html` when mounting `Files::new("/", "./static")`, + /// configure it as `.index_file("index.html")` (not `.index_file("./static/index.html")`). /// /// If the index file is not found, files listing is shown as a fallback if /// [`Files::show_files_listing()`] is set.