Struct gotham::handler::FileOptions
source · [−]pub struct FileOptions { /* private fields */ }
Expand description
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);
Implementations
sourceimpl FileOptions
impl FileOptions
sourcepub fn new<P: AsRef<Path>>(path: P) -> Self where
PathBuf: From<P>,
pub fn new<P: AsRef<Path>>(path: P) -> Self where
PathBuf: From<P>,
Create a new FileOptions
with default values.
sourcepub fn with_cache_control(&mut self, cache_control: &str) -> &mut Self
pub fn with_cache_control(&mut self, cache_control: &str) -> &mut Self
Sets the “cache_control” header in static file responses to the given value.
sourcepub fn with_gzip(&mut self, gzip: bool) -> &mut Self
pub fn with_gzip(&mut self, gzip: bool) -> &mut Self
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).
sourcepub fn with_brotli(&mut self, brotli: bool) -> &mut Self
pub fn with_brotli(&mut self, brotli: bool) -> &mut Self
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).
Trait Implementations
sourceimpl Clone for FileOptions
impl Clone for FileOptions
sourcefn clone(&self) -> FileOptions
fn clone(&self) -> FileOptions
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for FileOptions
impl Debug for FileOptions
sourceimpl<'a> From<&'a Path> for FileOptions
impl<'a> From<&'a Path> for FileOptions
sourcefn from(t: &'a Path) -> FileOptions
fn from(t: &'a Path) -> FileOptions
Converts to this type from the input type.
sourceimpl<'a> From<&'a String> for FileOptions
impl<'a> From<&'a String> for FileOptions
sourcefn from(t: &'a String) -> FileOptions
fn from(t: &'a String) -> FileOptions
Converts to this type from the input type.
sourceimpl<'a> From<&'a str> for FileOptions
impl<'a> From<&'a str> for FileOptions
sourcefn from(t: &'a str) -> FileOptions
fn from(t: &'a str) -> FileOptions
Converts to this type from the input type.
sourceimpl<'a> From<PathBuf> for FileOptions
impl<'a> From<PathBuf> for FileOptions
sourcefn from(t: PathBuf) -> FileOptions
fn from(t: PathBuf) -> FileOptions
Converts to this type from the input type.
sourceimpl<'a> From<String> for FileOptions
impl<'a> From<String> for FileOptions
sourcefn from(t: String) -> FileOptions
fn from(t: String) -> FileOptions
Converts to this type from the input type.
sourceimpl PartialEq<FileOptions> for FileOptions
impl PartialEq<FileOptions> for FileOptions
sourcefn eq(&self, other: &FileOptions) -> bool
fn eq(&self, other: &FileOptions) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &FileOptions) -> bool
fn ne(&self, other: &FileOptions) -> bool
This method tests for !=
.
impl StructuralPartialEq for FileOptions
Auto Trait Implementations
impl RefUnwindSafe for FileOptions
impl Send for FileOptions
impl Sync for FileOptions
impl Unpin for FileOptions
impl UnwindSafe for FileOptions
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more