pub struct MiddlewarePipeline { /* private fields */ }Implementations§
Source§impl MiddlewarePipeline
impl MiddlewarePipeline
pub fn new() -> MiddlewarePipeline
pub fn add_middleware(&mut self, middleware: Arc<dyn IMiddleware>)
Sourcepub async fn execute(
&self,
ctx: &mut dyn IHttpContext,
final_handler: Arc<dyn for<'a> Fn(&'a mut dyn IHttpContext) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> + Sync + Send>,
) -> Result<(), Error>
pub async fn execute( &self, ctx: &mut dyn IHttpContext, final_handler: Arc<dyn for<'a> Fn(&'a mut dyn IHttpContext) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> + Sync + Send>, ) -> Result<(), Error>
Execute middleware onion: invoke forward, final handler, after hooks reverse.
Supports short-circuit: if a middleware’s invoke returns
ControlFlow::Break(()), remaining middleware and the final handler are
skipped.
after hooks always run for the middleware whose invoke completed,
including when the request fails: an error raised by a middleware or by
the final handler must still let metrics, tracing, gzip and cleanup
observe the response. The first error is returned after the unwind; a
failure inside an after hook is logged and never masks the original
error.
Trait Implementations§
Source§impl Default for MiddlewarePipeline
impl Default for MiddlewarePipeline
Source§fn default() -> MiddlewarePipeline
fn default() -> MiddlewarePipeline
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for MiddlewarePipeline
impl !UnwindSafe for MiddlewarePipeline
impl Forget for MiddlewarePipeline
impl Freeze for MiddlewarePipeline
impl Send for MiddlewarePipeline
impl Sync for MiddlewarePipeline
impl Unpin for MiddlewarePipeline
impl UnsafeUnpin for MiddlewarePipeline
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more