EnhancedMiddleware

Trait EnhancedMiddleware 

Source
pub trait EnhancedMiddleware: Send + Sync {
    // Required methods
    fn before_request<'life0, 'life1, 'async_trait>(
        &'life0 self,
        request: &'life1 mut Request,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Response>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn after_response<'life0, 'life1, 'async_trait>(
        &'life0 self,
        response: &'life1 mut Response,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn name(&self) -> &'static str;

    // Provided method
    fn is_enabled(&self) -> bool { ... }
}
Expand description

Enhanced middleware trait with configuration support

Required Methods§

Source

fn before_request<'life0, 'life1, 'async_trait>( &'life0 self, request: &'life1 mut Request, ) -> Pin<Box<dyn Future<Output = Result<Option<Response>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Process a request before it reaches the handler

Source

fn after_response<'life0, 'life1, 'async_trait>( &'life0 self, response: &'life1 mut Response, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Process a response after the handler

Source

fn name(&self) -> &'static str

Get middleware name for debugging/logging

Provided Methods§

Source

fn is_enabled(&self) -> bool

Check if middleware is enabled

Implementors§