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:
@ -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.
|
||||
|
Reference in New Issue
Block a user