pub struct ResponseInterceptorStack { /* private fields */ }Expand description
A stack of response interceptors that run in order.
Interceptors are executed in registration order (first registered, first run). Each interceptor receives the response from the previous one and can modify it.
§Example
ⓘ
let mut stack = ResponseInterceptorStack::new();
stack.push(TimingInterceptor);
stack.push(DebugHeadersInterceptor::new());
let response = stack.process(&ctx, response).await;Implementations§
Source§impl ResponseInterceptorStack
impl ResponseInterceptorStack
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a stack with pre-allocated capacity.
Sourcepub fn push<I: ResponseInterceptor + 'static>(&mut self, interceptor: I)
pub fn push<I: ResponseInterceptor + 'static>(&mut self, interceptor: I)
Add an interceptor to the end of the stack.
Sourcepub fn push_arc(&mut self, interceptor: Arc<dyn ResponseInterceptor>)
pub fn push_arc(&mut self, interceptor: Arc<dyn ResponseInterceptor>)
Add an Arc-wrapped interceptor.
Sourcepub async fn process(
&self,
ctx: &ResponseInterceptorContext<'_>,
response: Response,
) -> Response
pub async fn process( &self, ctx: &ResponseInterceptorContext<'_>, response: Response, ) -> Response
Process a response through all interceptors.
Trait Implementations§
Source§impl Default for ResponseInterceptorStack
impl Default for ResponseInterceptorStack
Source§fn default() -> ResponseInterceptorStack
fn default() -> ResponseInterceptorStack
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ResponseInterceptorStack
impl !RefUnwindSafe for ResponseInterceptorStack
impl Send for ResponseInterceptorStack
impl Sync for ResponseInterceptorStack
impl Unpin for ResponseInterceptorStack
impl !UnwindSafe for ResponseInterceptorStack
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).