1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 01:51:23 +02:00

fix static files

This commit is contained in:
Nikolay Kim
2017-12-08 12:29:28 -08:00
parent 774bfc0a86
commit 3e91b06241
5 changed files with 35 additions and 16 deletions

View File

@ -25,7 +25,9 @@ fn main() {
## Directory
To serve files from specific directory and sub-directories `StaticFiles` could be used.
`StaticFiles` could be registered with `Application::route` method.
`StaticFiles` could be registered with `Application::resource` method.
`StaticFiles` requires tail named path expression for resource registration.
And this name has to be used in `StaticFile` constructor.
```rust
# extern crate actix_web;
@ -33,11 +35,12 @@ use actix_web::*;
fn main() {
Application::new("/")
.resource("/static", |r| r.h(fs::StaticFiles::new(".", true)))
.resource("/static/{tail:.*}", |r| r.h(fs::StaticFiles::new("tail", ".", true)))
.finish();
}
```
First parameter is a base directory. Second parameter is *show_index*, if it is set to *true*
First parameter is a name of path pattern. Second parameter is a base directory.
Third parameter is *show_index*, if it is set to *true*
directory listing would be returned for directories, if it is set to *false*
then *404 Not Found* would be returned instead of directory listing.