Skip to main content

Interceptor

Trait Interceptor 

Source
pub trait Interceptor:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn intercept<'a>(
        &'a self,
        context: ExecutionContext,
        next: CallHandler<'a>,
    ) -> BoxFuture<'a, Result<BootResponse>> { ... }
    fn before(
        &self,
        _context: ExecutionContext,
    ) -> BoxFuture<'static, Result<()>> { ... }
    fn short_circuit(
        &self,
        _context: ExecutionContext,
    ) -> BoxFuture<'static, Result<Option<BootResponse>>> { ... }
    fn after(
        &self,
        _context: ExecutionContext,
        response: BootResponse,
    ) -> BoxFuture<'static, Result<BootResponse>> { ... }
}
Expand description

Runs around the handler for cross-cutting behavior.

Provided Methods§

Source

fn intercept<'a>( &'a self, context: ExecutionContext, next: CallHandler<'a>, ) -> BoxFuture<'a, Result<BootResponse>>

Run around the remaining HTTP pipeline.

Override this method to catch or replace downstream errors, retry the handler, apply a timeout, or return a response without calling next. The default implementation preserves the legacy before, short_circuit, and after hook behavior.

Source

fn before(&self, _context: ExecutionContext) -> BoxFuture<'static, Result<()>>

Source

fn short_circuit( &self, _context: ExecutionContext, ) -> BoxFuture<'static, Result<Option<BootResponse>>>

Source

fn after( &self, _context: ExecutionContext, response: BootResponse, ) -> BoxFuture<'static, Result<BootResponse>>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Interceptor for SerializationInterceptor

Source§

impl<F, Fut> Interceptor for F
where F: Fn(ExecutionContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<()>> + Send + 'static,