pub struct StaticFilesConfig {
pub directory: PathBuf,
pub prefix: String,
pub index_files: Vec<String>,
pub show_hidden: bool,
pub follow_symlinks: bool,
pub enable_etag: bool,
pub enable_last_modified: bool,
pub directory_listing: bool,
pub not_found_page: Option<String>,
pub extra_headers: Vec<(String, String)>,
}Expand description
Configuration for static file serving.
Fields§
§directory: PathBufRoot directory to serve files from.
prefix: StringURL path prefix (e.g., “/static”).
index_files: Vec<String>Index files to look for in directories.
Whether to serve hidden files (starting with .).
follow_symlinks: boolWhether to follow symlinks.
enable_etag: boolWhether to generate ETag headers.
enable_last_modified: boolWhether to add Last-Modified headers.
directory_listing: boolWhether to enable directory listing.
not_found_page: Option<String>Custom 404 page path (relative to directory).
extra_headers: Vec<(String, String)>Additional headers to add to all responses.
Implementations§
Source§impl StaticFilesConfig
impl StaticFilesConfig
Sourcepub fn new(directory: impl Into<PathBuf>) -> Self
pub fn new(directory: impl Into<PathBuf>) -> Self
Create a new configuration with the given directory.
Sourcepub fn index_files(self, files: Vec<String>) -> Self
pub fn index_files(self, files: Vec<String>) -> Self
Set the index files to look for.
Enable or disable showing hidden files.
Sourcepub fn follow_symlinks(self, follow: bool) -> Self
pub fn follow_symlinks(self, follow: bool) -> Self
Enable or disable following symlinks.
Sourcepub fn enable_etag(self, enable: bool) -> Self
pub fn enable_etag(self, enable: bool) -> Self
Enable or disable ETag generation.
Sourcepub fn enable_last_modified(self, enable: bool) -> Self
pub fn enable_last_modified(self, enable: bool) -> Self
Enable or disable Last-Modified headers.
Sourcepub fn directory_listing(self, enable: bool) -> Self
pub fn directory_listing(self, enable: bool) -> Self
Enable or disable directory listing.
Sourcepub fn not_found_page(self, page: impl Into<String>) -> Self
pub fn not_found_page(self, page: impl Into<String>) -> Self
Set a custom 404 page.
Trait Implementations§
Source§impl Clone for StaticFilesConfig
impl Clone for StaticFilesConfig
Source§fn clone(&self) -> StaticFilesConfig
fn clone(&self) -> StaticFilesConfig
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 Debug for StaticFilesConfig
impl Debug for StaticFilesConfig
Auto Trait Implementations§
impl Freeze for StaticFilesConfig
impl RefUnwindSafe for StaticFilesConfig
impl Send for StaticFilesConfig
impl Sync for StaticFilesConfig
impl Unpin for StaticFilesConfig
impl UnwindSafe for StaticFilesConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).