pub struct ResponseBodyTransform<F>{ /* private fields */ }Expand description
A response transformer that applies a function to the response body.
This is useful for content transformations like:
- Minification
- Pretty-printing
- Wrapping responses
- Filtering content
§Example
ⓘ
// Wrap JSON responses in an envelope
let transformer = ResponseBodyTransform::new(|body| {
format!(r#"{{"data": {}}}"#, String::from_utf8_lossy(&body)).into_bytes()
});Implementations§
Source§impl<F> ResponseBodyTransform<F>
impl<F> ResponseBodyTransform<F>
Trait Implementations§
Source§impl<F> ResponseInterceptor for ResponseBodyTransform<F>
impl<F> ResponseInterceptor for ResponseBodyTransform<F>
Auto Trait Implementations§
impl<F> Freeze for ResponseBodyTransform<F>where
F: Freeze,
impl<F> RefUnwindSafe for ResponseBodyTransform<F>where
F: RefUnwindSafe,
impl<F> Send for ResponseBodyTransform<F>
impl<F> Sync for ResponseBodyTransform<F>
impl<F> Unpin for ResponseBodyTransform<F>where
F: Unpin,
impl<F> UnwindSafe for ResponseBodyTransform<F>where
F: UnwindSafe,
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).