#[non_exhaustive]pub struct StaticFilesHandler {
pub path: String,
pub upload_path_regex: String,
pub http_headers: HashMap<String, String>,
pub mime_type: String,
pub expiration: Option<Duration>,
pub require_matching_file: bool,
pub application_readable: bool,
/* private fields */
}
Expand description
Files served directly to the user for a given URL, such as images, CSS stylesheets, or JavaScript source files. Static file handlers describe which files in the application directory are static files, and which URLs serve them.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.path: String
Path to the static files matched by the URL pattern, from the application root directory. The path can refer to text matched in groupings in the URL pattern.
upload_path_regex: String
Regular expression that matches the file paths for all files that should be referenced by this handler.
http_headers: HashMap<String, String>
HTTP headers to use for all responses from these URLs.
mime_type: String
MIME type used to serve all files served by this handler.
Defaults to file-specific MIME types, which are derived from each file’s filename extension.
expiration: Option<Duration>
Time a static file served by this handler should be cached by web proxies and browsers.
require_matching_file: bool
Whether this handler should match the request if the file referenced by the handler does not exist.
application_readable: bool
Whether files should also be uploaded as code data. By default, files declared in static file handlers are uploaded as static data and are only served to end users; they cannot be read by the application. If enabled, uploads are charged against both your code and static data storage resource quotas.
Implementations§
Source§impl StaticFilesHandler
impl StaticFilesHandler
pub fn new() -> Self
Sourcepub fn set_upload_path_regex<T: Into<String>>(self, v: T) -> Self
pub fn set_upload_path_regex<T: Into<String>>(self, v: T) -> Self
Sets the value of upload_path_regex.
Sourcepub fn set_http_headers<T, K, V>(self, v: T) -> Self
pub fn set_http_headers<T, K, V>(self, v: T) -> Self
Sets the value of http_headers.
Sourcepub fn set_mime_type<T: Into<String>>(self, v: T) -> Self
pub fn set_mime_type<T: Into<String>>(self, v: T) -> Self
Sets the value of mime_type.
Sourcepub fn set_expiration<T>(self, v: T) -> Self
pub fn set_expiration<T>(self, v: T) -> Self
Sets the value of expiration.
Sourcepub fn set_or_clear_expiration<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_expiration<T>(self, v: Option<T>) -> Self
Sets or clears the value of expiration.
Sourcepub fn set_require_matching_file<T: Into<bool>>(self, v: T) -> Self
pub fn set_require_matching_file<T: Into<bool>>(self, v: T) -> Self
Sets the value of require_matching_file.
Sourcepub fn set_application_readable<T: Into<bool>>(self, v: T) -> Self
pub fn set_application_readable<T: Into<bool>>(self, v: T) -> Self
Sets the value of application_readable.
Trait Implementations§
Source§impl Clone for StaticFilesHandler
impl Clone for StaticFilesHandler
Source§fn clone(&self) -> StaticFilesHandler
fn clone(&self) -> StaticFilesHandler
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more