pub struct ContentHandler<H> { /* private fields */ }Expand description
Handles content encoding and decoding for HTTP requests and responses.
ContentHandler is responsible for:
- Decoding the content of incoming requests based on their Content-Encoding header.
- Encoding the content of outgoing responses based on the client’s Accept-Encoding preferences.
It wraps an inner handler and preprocesses requests before passing them to the inner handler, as well as postprocessing responses from the inner handler. For implementation details and example usage, see the module level documentation.
Implementations§
Source§impl<F> ContentHandler<F>
impl<F> ContentHandler<F>
pub fn layer<C>() -> impl FactoryLayer<C, F, Factory = Self>
Sourcepub fn opt_layer<C>(
enabled: bool,
) -> Option<impl FactoryLayer<C, F, Factory = Self>>
pub fn opt_layer<C>( enabled: bool, ) -> Option<impl FactoryLayer<C, F, Factory = Self>>
Returns a factory layer for the ContentHandler.
This allows the ’ContentHandler to be selectively enabled or disabled based on a configuration at runtime.
Trait Implementations§
Source§impl<F: AsyncMakeService> AsyncMakeService for ContentHandler<F>
impl<F: AsyncMakeService> AsyncMakeService for ContentHandler<F>
Source§type Service = ContentHandler<<F as AsyncMakeService>::Service>
type Service = ContentHandler<<F as AsyncMakeService>::Service>
The type of service this factory creates.
Source§type Error = <F as AsyncMakeService>::Error
type Error = <F as AsyncMakeService>::Error
The type of error that can occur during service creation.
Source§impl<H: Clone> Clone for ContentHandler<H>
impl<H: Clone> Clone for ContentHandler<H>
Source§fn clone(&self) -> ContentHandler<H>
fn clone(&self) -> ContentHandler<H>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F> MakeService for ContentHandler<F>where
F: MakeService,
impl<F> MakeService for ContentHandler<F>where
F: MakeService,
Source§type Service = ContentHandler<<F as MakeService>::Service>
type Service = ContentHandler<<F as MakeService>::Service>
The type of service this factory creates.
Source§type Error = <F as MakeService>::Error
type Error = <F as MakeService>::Error
The type of error that can occur during service creation.
Source§impl<H, CX, B> Service<(Request<B>, CX)> for ContentHandler<H>where
H: HttpHandler<CX, B>,
B: BodyEncodeExt + FixedBody,
H::Body: BodyEncodeExt + FixedBody,
B::EncodeDecodeError: Debug,
<H::Body as BodyEncodeExt>::EncodeDecodeError: Debug,
impl<H, CX, B> Service<(Request<B>, CX)> for ContentHandler<H>where
H: HttpHandler<CX, B>,
B: BodyEncodeExt + FixedBody,
H::Body: BodyEncodeExt + FixedBody,
B::EncodeDecodeError: Debug,
<H::Body as BodyEncodeExt>::EncodeDecodeError: Debug,
Auto Trait Implementations§
impl<H> Freeze for ContentHandler<H>where
H: Freeze,
impl<H> RefUnwindSafe for ContentHandler<H>where
H: RefUnwindSafe,
impl<H> Send for ContentHandler<H>where
H: Send,
impl<H> Sync for ContentHandler<H>where
H: Sync,
impl<H> Unpin for ContentHandler<H>where
H: Unpin,
impl<H> UnwindSafe for ContentHandler<H>where
H: 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