1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
use crate::{response::ResponderError, Body, Request, Response}; use async_trait::async_trait; use std::sync::Arc; #[async_trait] pub trait RequestMiddleware<M> where M: 'static + Sync + Send, { type HandlerArgs: 'static + Sync + Send; type Error: ResponderError; type Type; async fn call( req: &mut Request<Body>, module: Arc<M>, ha: Self::HandlerArgs, ) -> Result<Self::Type, Self::Error>; } #[async_trait] pub trait ResponseMiddleware<M> where M: 'static + Sync + Send, { type HandlerArgs; type Error: ResponderError; type Type; async fn call( r: &mut Response<Body>, module: Arc<M>, ha: Self::HandlerArgs, ) -> Result<Self::Type, Self::Error>; }