1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-01 16:55:08 +02:00

simplify StaticFiles

This commit is contained in:
Nikolay Kim
2018-04-06 19:34:55 -07:00
parent 602d78b76c
commit 542315ce7f
7 changed files with 35 additions and 29 deletions

View File

@ -34,16 +34,21 @@ use actix_web::*;
fn main() {
App::new()
.handler("/static", fs::StaticFiles::new(".", true))
.handler(
"/static",
fs::StaticFiles::new(".")
.show_folder_listing())
.finish();
}
```
The first parameter is the base directory. If the second parameter, *show_index*, is set to **true**,
the directory listing will be returned, and if it is set to **false**,
*404 Not Found* will be returned.
The parameter is the base directory. By default files listing for sub-directories
is disabled. Attempt to load directory listing will return *404 Not Found* response.
To enable files listing, use
[*StaticFiles::show_files_listing()*](../actix_web/s/struct.StaticFiles.html#method.show_files_listing)
method.
Instead of showing files listing for directory, it is possible to redirect to a specific
index file. Use the
Instead of showing files listing for directory, it is possible to redirect
to a specific index file. Use the
[*StaticFiles::index_file()*](../actix_web/s/struct.StaticFiles.html#method.index_file)
method to configure this redirect.