MiddlewareLayer

Trait MiddlewareLayer 

Source
pub trait MiddlewareLayer:
    Send
    + Sync
    + 'static {
    // Required methods
    fn call(
        &self,
        req: Request,
        next: Arc<dyn Fn(Request) -> Pin<Box<dyn Future<Output = Response<Full<Bytes>>> + Send>> + Send + Sync>,
    ) -> Pin<Box<dyn Future<Output = Response<Full<Bytes>>> + Send>>;
    fn clone_box(&self) -> Box<dyn MiddlewareLayer>;
}
Expand description

Trait for middleware that can be applied to RustAPI

This trait allows both Tower layers and custom middleware to be used with the .layer() method.

Required Methods§

Source

fn call( &self, req: Request, next: Arc<dyn Fn(Request) -> Pin<Box<dyn Future<Output = Response<Full<Bytes>>> + Send>> + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Response<Full<Bytes>>> + Send>>

Apply this middleware to a request, calling next to continue the chain

Source

fn clone_box(&self) -> Box<dyn MiddlewareLayer>

Clone this middleware into a boxed trait object

Implementors§