mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-01 16:55:08 +02:00
simplify StaticFiles
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user