[−][src]Struct gotham::handler::assets::FileOptions
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]
PathBuf: From<P>,
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]
fn from(t: &'a Path) -> FileOptions
[src]
impl<'a> From<PathBuf> for FileOptions
[src]
fn from(t: PathBuf) -> FileOptions
[src]
impl<'a> From<&'a str> for FileOptions
[src]
fn from(t: &'a str) -> FileOptions
[src]
impl<'a> From<&'a String> for FileOptions
[src]
fn from(t: &'a String) -> FileOptions
[src]
impl<'a> From<String> for FileOptions
[src]
fn from(t: String) -> FileOptions
[src]
impl PartialEq<FileOptions> for FileOptions
[src]
fn eq(&self, other: &FileOptions) -> bool
[src]
fn ne(&self, other: &FileOptions) -> bool
[src]
impl Clone for FileOptions
[src]
fn clone(&self) -> 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
impl Unpin for FileOptions
impl Sync for FileOptions
impl Send for FileOptions
impl RefUnwindSafe for FileOptions
impl UnwindSafe for FileOptions
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,