pub struct SendfileMiddleware { /* private fields */ }Expand description
X-Sendfile middleware
Handles X-Sendfile headers from upstream applications to serve files directly from disk instead of proxying through the application.
Implementations§
Trait Implementations§
Source§impl Default for SendfileMiddleware
impl Default for SendfileMiddleware
Source§impl Middleware for SendfileMiddleware
impl Middleware for SendfileMiddleware
Source§fn request_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
_ctx: &'life2 mut MiddlewareContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn request_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
_ctx: &'life2 mut MiddlewareContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Add X-Sendfile-Type header to request
This informs the upstream application that we support X-Sendfile, allowing it to respond with X-Sendfile headers for static files.
Source§fn response_filter<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_session: &'life1 mut Session,
upstream_response: &'life2 mut ResponseHeader,
ctx: &'life3 mut MiddlewareContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn response_filter<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_session: &'life1 mut Session,
upstream_response: &'life2 mut ResponseHeader,
ctx: &'life3 mut MiddlewareContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Check for X-Sendfile header in response and handle file serving
If X-Sendfile header is present:
- Extract file path
- Validate path for security
- Set Content-Length from file size
- Mark sendfile as active in context
- Remove X-Sendfile header (internal implementation detail)
Auto Trait Implementations§
impl Freeze for SendfileMiddleware
impl RefUnwindSafe for SendfileMiddleware
impl Send for SendfileMiddleware
impl Sync for SendfileMiddleware
impl Unpin for SendfileMiddleware
impl UnwindSafe for SendfileMiddleware
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