pub trait MiddlewareLayer:
Send
+ Sync
+ 'static {
// Required methods
fn call(
&self,
req: Request,
next: BoxedNext,
) -> Pin<Box<dyn Future<Output = Response> + Send + 'static>>;
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§
Sourcefn call(
&self,
req: Request,
next: BoxedNext,
) -> Pin<Box<dyn Future<Output = Response> + Send + 'static>>
fn call( &self, req: Request, next: BoxedNext, ) -> Pin<Box<dyn Future<Output = Response> + Send + 'static>>
Apply this middleware to a request, calling next to continue the chain
Sourcefn clone_box(&self) -> Box<dyn MiddlewareLayer>
fn clone_box(&self) -> Box<dyn MiddlewareLayer>
Clone this middleware into a boxed trait object