[−][src]Struct actix_web::fs::StaticFiles
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(); }
Methods
impl<S: 'static> StaticFiles<S>
[src]
impl<S: 'static> StaticFiles<S>
pub fn new<T: Into<PathBuf>>(dir: T) -> Result<StaticFiles<S>, Error>
[src]
pub fn new<T: Into<PathBuf>>(dir: T) -> Result<StaticFiles<S>, Error>
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.
pub fn with_pool<T: Into<PathBuf>>(
dir: T,
pool: CpuPool
) -> Result<StaticFiles<S>, Error>
[src]
pub fn with_pool<T: Into<PathBuf>>(
dir: T,
pool: CpuPool
) -> Result<StaticFiles<S>, Error>
Create new StaticFiles
instance for specified base directory and
CpuPool
.
impl<S: 'static, C: StaticFileConfig> StaticFiles<S, C>
[src]
impl<S: 'static, C: StaticFileConfig> StaticFiles<S, C>
pub fn with_config<T: Into<PathBuf>>(
dir: T,
config: C
) -> Result<StaticFiles<S, C>, Error>
[src]
pub fn with_config<T: Into<PathBuf>>(
dir: T,
config: C
) -> Result<StaticFiles<S, C>, Error>
Create new StaticFiles
instance for specified base directory.
Identical with new
but allows to specify configiration to use.
pub fn with_config_pool<T: Into<PathBuf>>(
dir: T,
pool: CpuPool,
_: C
) -> Result<StaticFiles<S, C>, Error>
[src]
pub fn with_config_pool<T: Into<PathBuf>>(
dir: T,
pool: CpuPool,
_: C
) -> Result<StaticFiles<S, C>, Error>
Create new StaticFiles
instance for specified base directory with config and
CpuPool
.
pub fn show_files_listing(self) -> Self
[src]
pub fn show_files_listing(self) -> Self
Show files listing for directories.
By default show files listing is disabled.
pub fn files_listing_renderer<F>(self, f: F) -> Self where
F: Fn(&'r Directory, &'s HttpRequest<S>) -> Result<HttpResponse, Error> + 'static,
[src]
pub fn files_listing_renderer<F>(self, f: F) -> Self where
F: Fn(&'r Directory, &'s HttpRequest<S>) -> Result<HttpResponse, Error> + 'static,
Set custom directory renderer
pub fn index_file<T: Into<String>>(self, index: T) -> StaticFiles<S, C>
[src]
pub fn index_file<T: Into<String>>(self, index: T) -> StaticFiles<S, C>
Set index file
Redirects to specific index file for directory "/" instead of showing files listing.
pub fn default_handler<H: Handler<S>>(self, handler: H) -> StaticFiles<S, C>
[src]
pub fn default_handler<H: Handler<S>>(self, handler: H) -> StaticFiles<S, C>
Sets default handler which is used when no matched file could be found.
Trait Implementations
impl<S: 'static, C: 'static + StaticFileConfig> Handler<S> for StaticFiles<S, C>
[src]
impl<S: 'static, C: 'static + StaticFileConfig> Handler<S> for StaticFiles<S, C>
type Result = Result<AsyncResult<HttpResponse>, Error>
The type of value that handler will return.
fn handle(&self, req: &HttpRequest<S>) -> Self::Result
[src]
fn handle(&self, req: &HttpRequest<S>) -> Self::Result
Handle request
Auto Trait Implementations
impl<S, C = DefaultConfig> !Send for StaticFiles<S, C>
impl<S, C = DefaultConfig> !Send for StaticFiles<S, C>
impl<S, C = DefaultConfig> !Sync for StaticFiles<S, C>
impl<S, C = DefaultConfig> !Sync for StaticFiles<S, C>
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
impl<T> Erased for T