pub struct Compress<T> { /* private fields */ }
Available 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
sourceimpl<T> Compress<T>
impl<T> Compress<T>
sourcepub fn new(inner: T, algo: CompressionAlgo) -> Self
pub fn new(inner: T, algo: CompressionAlgo) -> Self
Create a compressed response using the specified algorithm.
sourcepub fn with_quality(self, level: CompressionLevel) -> Self
pub fn with_quality(self, level: CompressionLevel) -> Self
Specify the compression level
Trait Implementations
sourceimpl<T: IntoResponse> IntoResponse for Compress<T>
impl<T: IntoResponse> IntoResponse for Compress<T>
sourcefn into_response(self) -> Response
fn into_response(self) -> Response
Consume itself and return
Response
.sourcefn 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 moresourcefn with_content_type<V>(self, content_type: V) -> WithContentType<Self>where
V: TryInto<HeaderValue>,
Self: Sized,
fn with_content_type<V>(self, content_type: V) -> WithContentType<Self>where
V: TryInto<HeaderValue>,
Self: Sized,
Wrap an
impl IntoResponse
to with a new content type. Read moresourcefn with_status(self, status: StatusCode) -> WithStatus<Self>where
Self: Sized,
fn with_status(self, status: StatusCode) -> WithStatus<Self>where
Self: Sized,
Wrap an
impl IntoResponse
to set a status code. Read moreAuto Trait Implementations
impl<T> RefUnwindSafe for Compress<T>where
T: RefUnwindSafe,
impl<T> Send for Compress<T>where
T: Send,
impl<T> Sync for Compress<T>where
T: Sync,
impl<T> Unpin for Compress<T>where
T: Unpin,
impl<T> UnwindSafe for Compress<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> FutureExt for T
impl<T> FutureExt for T
fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoResult<T> for Twhere
T: IntoResponse,
impl<T> IntoResult<T> for Twhere
T: IntoResponse,
sourcefn into_result(self) -> Result<T, Error>
fn into_result(self) -> Result<T, Error>
Consumes this value returns a
poem::Result<T>
.