logo
pub struct Options {
    pub folder_default: Option<String>,
    pub extension_default: Option<String>,
    pub public_data_dir: Option<PathBuf>,
    pub errors_dir: Option<PathBuf>,
    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

Options for Host. Values wrapped in Options usually use hardcoded defaults when the value is None.

This can easily be cloned to be shared across multiple hosts.

Fields

folder_default: Option<String>

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<String>

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<PathBuf>

Default data directory for public files. Default is public.

errors_dir: Option<PathBuf>

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 StatusCodes.

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

Creates a new Options with default settings.

All Options are None and all booleans are false. Self::status_code_cache_filter uses default_status_code_cache_filter.

Disables client cache on this host.

This makes all comprash::ClientCachePreferences no-store. Use Kvarn extensions’ force_cache to force certain files to cache.

Disables accessing the file system for public files.

See Self::disable_fs for more info.

Sets the directory (relative to the Host::path) to fetch data for the web in. Defaults to public.

Sets the directory (relative to the Host::path) to get HTTP error overrides from. Defaults to errors.

Gets the Self::folder_default, as used by Kvarn. Uses the default specified there.

Gets the Self::extension_default, as used by Kvarn. Uses the default specified there.

Gets the Self::public_data_dir, as used by Kvarn. Uses the default specified there.

Gets the Self::errors_dir, as used by Kvarn. Uses the default specified there.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more