pub struct StaticFiles { /* private fields */ }Expand description
Serves static files rooted at a directory.
Security: request paths are percent-decoded, normalized, and any ..
component is rejected, so a request can never escape the configured root.
Symlinks that point outside the root are also rejected via canonicalization.
Behavior:
GETandHEADare supported; other methods get405.- A request for a directory serves its
index.htmlif present, else404(directory listings are intentionally not generated). Last-Modifiedand a weak-ishETagare emitted;If-None-MatchandIf-Modified-Sinceproduce304when they match.- A single
Rangerequest is honored with a206response; multi-range requests fall back to the full body.
Implementations§
Source§impl StaticFiles
impl StaticFiles
Sourcepub fn new(root: impl Into<PathBuf>) -> StaticFiles
pub fn new(root: impl Into<PathBuf>) -> StaticFiles
Serve files from root, using index.html as the directory index.
Sourcepub fn index(self, name: impl Into<String>) -> StaticFiles
pub fn index(self, name: impl Into<String>) -> StaticFiles
Override the directory index file name (default index.html).
Trait Implementations§
Source§impl Clone for StaticFiles
impl Clone for StaticFiles
Source§fn clone(&self) -> StaticFiles
fn clone(&self) -> StaticFiles
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 StaticFiles
impl Debug for StaticFiles
Auto Trait Implementations§
impl Freeze for StaticFiles
impl RefUnwindSafe for StaticFiles
impl Send for StaticFiles
impl Sync for StaticFiles
impl Unpin for StaticFiles
impl UnsafeUnpin for StaticFiles
impl UnwindSafe for StaticFiles
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