[][src]Struct gotham::handler::assets::FileOptions

pub struct FileOptions { /* fields omitted */ }

Options to pass to file or dir handlers. Allows overriding default behaviour for compression, cache control headers, etc.

FileOptions implements From for String and PathBuf (and related reference types) - so that a path can be passed to router builder methods if only default options are required.

For overridding default options, FileOptions provides builder methods. The default values and use of the builder methods are shown in the example below.

let default_options = FileOptions::from("my_static_path");
let from_builder = FileOptions::new("my_static_path")
    .with_cache_control("public")
    .with_gzip(false)
    .with_brotli(false)
    .build();

assert_eq!(default_options, from_builder);

Methods

impl FileOptions[src]

pub fn new<P: AsRef<Path>>(path: P) -> Self where
    PathBuf: From<P>, 
[src]

Create a new FileOptions with default values.

pub fn with_cache_control(&mut self, cache_control: &str) -> &mut Self[src]

Sets the "cache_control" header in static file responses to the given value.

pub fn with_gzip(&mut self, gzip: bool) -> &mut Self[src]

If true, given a request for FILE, serves FILE.gz if it exists in the static directory and if the accept-encoding header is set to allow gzipped content (defaults to false).

pub fn with_brotli(&mut self, brotli: bool) -> &mut Self[src]

If true, given a request for FILE, serves FILE.br if it exists in the static directory and if the accept-encoding header is set to allow brotli content (defaults to false).

pub fn build(&mut self) -> Self[src]

Clones self to return an owned value for passing to a handler.

Trait Implementations

impl<'a> From<&'a Path> for FileOptions[src]

impl<'a> From<PathBuf> for FileOptions[src]

impl<'a> From<&'a str> for FileOptions[src]

impl<'a> From<&'a String> for FileOptions[src]

impl<'a> From<String> for FileOptions[src]

impl PartialEq<FileOptions> for FileOptions[src]

impl Clone for FileOptions[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for FileOptions[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T