pub struct Compress<T> { /* private fields */ }
This is supported on crate feature
compression
only.Expand description
Compress the response body with the specified algorithm and set the
Content-Encoding
header.
Example
use poem::{
handler,
web::{Compress, CompressionAlgo},
};
#[handler]
fn index() -> Compress<String> {
Compress::new("abcdef".to_string(), CompressionAlgo::GZIP)
}
Implementations
/// Create a compressed response using the specified algorithm.
Trait Implementations
Consume itself and return Response
.
fn with_header<K, V>(self, key: K, value: V) -> WithHeader<Self> where
K: TryInto<HeaderName>,
V: TryInto<HeaderValue>,
Self: Sized,
fn with_header<K, V>(self, key: K, value: V) -> WithHeader<Self> where
K: TryInto<HeaderName>,
V: TryInto<HeaderValue>,
Self: Sized,
Wrap an impl IntoResponse
to add a header. Read more
Wrap an impl IntoResponse
to set a status code. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for Compress<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Compress<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Consumes this value returns a poem::Result<T>
.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more