Middleware

Trait Middleware 

Source
pub trait Middleware: Send + Sync {
    // Provided methods
    fn before<'life0, 'async_trait>(
        &'life0 self,
        request: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn after<'life0, 'async_trait>(
        &'life0 self,
        request: Value,
        response: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn on_error<'life0, 'async_trait>(
        &'life0 self,
        request: Value,
        error: Error,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Middleware trait for request/response processing

Provided Methods§

Source

fn before<'life0, 'async_trait>( &'life0 self, request: Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process request before handler execution Returns modified request or error

Source

fn after<'life0, 'async_trait>( &'life0 self, request: Value, response: Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process response after handler execution Returns modified response or error

Source

fn on_error<'life0, 'async_trait>( &'life0 self, request: Value, error: Error, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle errors from handler or downstream middleware

Implementors§