pub struct Options {
pub folder_default: Option<CompactString>,
pub extension_default: Option<CompactString>,
pub public_data_dir: Option<CompactString>,
pub errors_dir: Option<CompactString>,
pub disable_client_cache: bool,
pub disable_if_modified_since: bool,
pub status_code_cache_filter: fn(_: StatusCode) -> CacheAction,
pub disable_fs: bool,
}
Expand description
Fields§
§folder_default: Option<CompactString>
Will be the default for folders; /js/
will resolve to /js/<folder_default>
.
E.g. /posts/
-> /posts/index.html
If no value is passed, index.html
is assumed.
extension_default: Option<CompactString>
Will be the default for unspecified file extensions; /foobar.
will resolve to /foobar.<extension_default>
.
E.g. /index.
-> /index.html
If no value is passed, html
is assumed.
public_data_dir: Option<CompactString>
Default data directory for public files.
Default is public
.
errors_dir: Option<CompactString>
Default directory for overriding HTTP error responses.
Default is errors
.
disable_client_cache: bool
Returns cache-control
header to be no-store
by default, if enabled.
Useful if you have a developing site and don’t want traditionally static content to be in the client cache.
disable_if_modified_since: bool
Disables further caching by sending a StatusCode::NOT_MODIFIED
when the
if-modified-since
header is sent and the resource is fresh.
status_code_cache_filter: fn(_: StatusCode) -> CacheAction
Filter to not cache certain StatusCode
s.
See CacheAction
and default_status_code_cache_filter
for more info.
disable_fs: bool
Disables file system access for public files.
This still enables custom error messages and reading of files through extensions.
Implementations§
source§impl Options
impl Options
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Options
with default settings.
All Option
s are None
and all booleans are false
.
Self::status_code_cache_filter
uses default_status_code_cache_filter
.
sourcepub fn disable_client_cache(&mut self) -> &mut Self
pub fn disable_client_cache(&mut self) -> &mut Self
Disables client cache on this host.
This makes all comprash::ClientCachePreference
s no-store
.
Use Kvarn extensions’ force_cache
to force certain files to cache.
sourcepub fn disable_fs(&mut self) -> &mut Self
pub fn disable_fs(&mut self) -> &mut Self
Disables accessing the file system for public files.
See Self::disable_fs
for more info.
sourcepub fn set_public_data_dir(&mut self, path: impl AsRef<str>) -> &mut Self
pub fn set_public_data_dir(&mut self, path: impl AsRef<str>) -> &mut Self
Sets the directory (relative to the Host::path
) to fetch data for the web in.
Defaults to public
.
sourcepub fn set_errors_dir(&mut self, path: impl AsRef<str>) -> &mut Self
pub fn set_errors_dir(&mut self, path: impl AsRef<str>) -> &mut Self
Sets the directory (relative to the Host::path
) to get HTTP error overrides from.
Defaults to errors
.
sourcepub fn get_folder_default(&self) -> &str
pub fn get_folder_default(&self) -> &str
Gets the Self::folder_default
, as used by Kvarn.
Uses the default specified there.
sourcepub fn get_extension_default(&self) -> &str
pub fn get_extension_default(&self) -> &str
Gets the Self::extension_default
, as used by Kvarn.
Uses the default specified there.
sourcepub fn get_public_data_dir(&self) -> &str
pub fn get_public_data_dir(&self) -> &str
Gets the Self::public_data_dir
, as used by Kvarn.
Uses the default specified there.
sourcepub fn get_errors_dir(&self) -> &str
pub fn get_errors_dir(&self) -> &str
Gets the Self::errors_dir
, as used by Kvarn.
Uses the default specified there.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Options
impl RefUnwindSafe for Options
impl Send for Options
impl Sync for Options
impl Unpin for Options
impl UnwindSafe for Options
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)