pub struct StaticFileConfig {
pub root: PathBuf,
pub prefix: String,
pub serve_index: bool,
pub index_file: String,
pub etag: bool,
pub last_modified: bool,
pub max_age: u64,
pub fallback: Option<String>,
}Expand description
Static file serving configuration
Fields§
§root: PathBufRoot directory for static files
prefix: StringURL path prefix
serve_index: boolWhether to serve index.html for directories
index_file: StringIndex file name (default: “index.html”)
etag: boolEnable ETag headers
last_modified: boolEnable Last-Modified headers
max_age: u64Cache-Control max-age in seconds (0 = no caching)
fallback: Option<String>Fallback file for SPA routing (e.g., “index.html”)
Implementations§
Source§impl StaticFileConfig
impl StaticFileConfig
Sourcepub fn new(
root: impl Into<PathBuf>,
prefix: impl Into<String>,
) -> StaticFileConfig
pub fn new( root: impl Into<PathBuf>, prefix: impl Into<String>, ) -> StaticFileConfig
Create a new static file configuration
Sourcepub fn serve_index(self, enabled: bool) -> StaticFileConfig
pub fn serve_index(self, enabled: bool) -> StaticFileConfig
Set whether to serve index.html for directories
Sourcepub fn index_file(self, name: impl Into<String>) -> StaticFileConfig
pub fn index_file(self, name: impl Into<String>) -> StaticFileConfig
Set the index file name
Sourcepub fn etag(self, enabled: bool) -> StaticFileConfig
pub fn etag(self, enabled: bool) -> StaticFileConfig
Enable or disable ETag headers
Sourcepub fn last_modified(self, enabled: bool) -> StaticFileConfig
pub fn last_modified(self, enabled: bool) -> StaticFileConfig
Enable or disable Last-Modified headers
Sourcepub fn max_age(self, seconds: u64) -> StaticFileConfig
pub fn max_age(self, seconds: u64) -> StaticFileConfig
Set Cache-Control max-age in seconds
Sourcepub fn fallback(self, file: impl Into<String>) -> StaticFileConfig
pub fn fallback(self, file: impl Into<String>) -> StaticFileConfig
Set a fallback file for SPA routing
Trait Implementations§
Source§impl Clone for StaticFileConfig
impl Clone for StaticFileConfig
Source§fn clone(&self) -> StaticFileConfig
fn clone(&self) -> StaticFileConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for StaticFileConfig
impl Default for StaticFileConfig
Source§fn default() -> StaticFileConfig
fn default() -> StaticFileConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StaticFileConfig
impl RefUnwindSafe for StaticFileConfig
impl Send for StaticFileConfig
impl Sync for StaticFileConfig
impl Unpin for StaticFileConfig
impl UnwindSafe for StaticFileConfig
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
Mutably borrows from an owned value. Read more