Struct actix_web::fs::StaticFiles

source ·
pub struct StaticFiles<S, C = DefaultConfig> { /* private fields */ }
Expand description

Static files handling

StaticFile handler must be registered with App::handler() method, because StaticFile handler requires access sub-path information.

use actix_web::{fs, App};

fn main() {
    let app = App::new()
        .handler("/static", fs::StaticFiles::new(".").unwrap())
        .finish();
}

Implementations

Create new StaticFiles instance for specified base directory.

StaticFile uses CpuPool for blocking filesystem operations. By default pool with 20 threads is used. Pool size can be changed by setting ACTIX_CPU_POOL environment variable.

Create new StaticFiles instance for specified base directory and CpuPool.

Create new StaticFiles instance for specified base directory.

Identical with new but allows to specify configiration to use.

Create new StaticFiles instance for specified base directory with config and CpuPool.

Show files listing for directories.

By default show files listing is disabled.

Set custom directory renderer

Set index file

Redirects to specific index file for directory “/” instead of showing files listing.

Sets default handler which is used when no matched file could be found.

Trait Implementations

The type of value that handler will return.
Handle request

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.