Skip to main content

Middleware

Trait Middleware 

Source
pub trait Middleware<C: Send + Sync>:
    Any
    + Send
    + Sync
    + 'static {
    // Required method
    fn name(&self) -> &str;

    // Provided methods
    fn process_request<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _client: &'life1 C,
        request: Request,
    ) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn process_response<'life0, 'async_trait>(
        &'life0 mut self,
        response: Response,
    ) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Response>, SpiderError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        _request: &'life1 Request,
        error: &'life2 SpiderError,
    ) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

A trait for processing requests and responses.

Required Methods§

Source

fn name(&self) -> &str

Provided Methods§

Source

fn process_request<'life0, 'life1, 'async_trait>( &'life0 mut self, _client: &'life1 C, request: Request, ) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

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

Source

fn handle_error<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, _request: &'life1 Request, error: &'life2 SpiderError, ) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Implementors§