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§
source§impl FileOptions
impl FileOptions
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).
sourcepub fn with_buffer_size(&mut self, buf_sz: usize) -> &mut Self
pub fn with_buffer_size(&mut self, buf_sz: usize) -> &mut Self
Sets the maximum buffer size to be used when serving the file. If unset, the default maximum buffer size corresponding to file system block size will be used.
Trait Implementations§
source§impl Clone for FileOptions
impl Clone for FileOptions
source§fn clone(&self) -> FileOptions
fn clone(&self) -> FileOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FileOptions
impl Debug for FileOptions
source§impl From<&Path> for FileOptions
impl From<&Path> for FileOptions
source§fn from(t: &Path) -> FileOptions
fn from(t: &Path) -> FileOptions
source§impl From<&String> for FileOptions
impl From<&String> for FileOptions
source§fn from(t: &String) -> FileOptions
fn from(t: &String) -> FileOptions
source§impl From<&str> for FileOptions
impl From<&str> for FileOptions
source§fn from(t: &str) -> FileOptions
fn from(t: &str) -> FileOptions
source§impl From<PathBuf> for FileOptions
impl From<PathBuf> for FileOptions
source§fn from(t: PathBuf) -> FileOptions
fn from(t: PathBuf) -> FileOptions
source§impl From<String> for FileOptions
impl From<String> for FileOptions
source§fn from(t: String) -> FileOptions
fn from(t: String) -> FileOptions
source§impl PartialEq for FileOptions
impl PartialEq for FileOptions
source§fn eq(&self, other: &FileOptions) -> bool
fn eq(&self, other: &FileOptions) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for FileOptions
impl StructuralPartialEq for FileOptions
Auto Trait Implementations§
impl Freeze for FileOptions
impl RefUnwindSafe for FileOptions
impl Send for FileOptions
impl Sync for FileOptions
impl Unpin for FileOptions
impl UnwindSafe for FileOptions
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.