pub struct SpaMiddleware { /* private fields */ }Expand description
SPA static file middleware.
- Matches
/{filename}against local filesystem - Serves files with auto-detected MIME types
- Falls back to
index.htmlfor unknown paths (SPA routing) - Only handles GET requests; non-GET passes through silently
Implementations§
Source§impl SpaMiddleware
impl SpaMiddleware
Sourcepub fn new(root: impl Into<PathBuf>) -> Self
pub fn new(root: impl Into<PathBuf>) -> Self
Create a new SPA middleware with default index “index.html”.
The root path is resolved relative to the current working directory.
If the directory doesn’t exist at that path, the middleware searches
upward through ancestor directories and their immediate subdirectories,
matching the strategy used by [config::load_appsettings].
Trait Implementations§
Source§impl IMiddleware for SpaMiddleware
impl IMiddleware for SpaMiddleware
Auto Trait Implementations§
impl Freeze for SpaMiddleware
impl RefUnwindSafe for SpaMiddleware
impl Send for SpaMiddleware
impl Sync for SpaMiddleware
impl Unpin for SpaMiddleware
impl UnsafeUnpin for SpaMiddleware
impl UnwindSafe for SpaMiddleware
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