pub struct CompressMiddleware { /* private fields */ }Expand description
A middleware for compressing response body data.
§Example
let mut app = tide::new();
app.with(tide_compress::CompressMiddleware::new());Implementations§
Source§impl CompressMiddleware
impl CompressMiddleware
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new CompressMiddleware.
Uses the defaults:
- Minimum body size threshold (1024 bytes).
- Check for
Content-Typeheader match^text/|\+(?:json|text|xml)$(case insensitive).
§Example
let mut app = tide::new();
app.with(tide_compress::CompressMiddleware::new());Sourcepub fn builder() -> CompressMiddlewareBuilder
pub fn builder() -> CompressMiddlewareBuilder
Used to create a new CompressMiddleware with custom settings.
Sourcepub fn set_threshold(&mut self, threshold: usize)
pub fn set_threshold(&mut self, threshold: usize)
Sets the minimum body size threshold value.
Sourcepub fn set_content_type_check(&mut self, content_type_check: Option<Regex>)
pub fn set_content_type_check(&mut self, content_type_check: Option<Regex>)
Sets the Content-Type header (MIME) check regular expression.
Sourcepub fn content_type_check(&self) -> Option<&Regex>
pub fn content_type_check(&self) -> Option<&Regex>
Gets a reference to the existing Content-Type header (MIME) check regular expression.
Trait Implementations§
Source§impl Clone for CompressMiddleware
impl Clone for CompressMiddleware
Source§fn clone(&self) -> CompressMiddleware
fn clone(&self) -> CompressMiddleware
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CompressMiddleware
impl Debug for CompressMiddleware
Source§impl Default for CompressMiddleware
impl Default for CompressMiddleware
Source§impl From<CompressMiddlewareBuilder> for CompressMiddleware
impl From<CompressMiddlewareBuilder> for CompressMiddleware
Source§fn from(builder: CompressMiddlewareBuilder) -> Self
fn from(builder: CompressMiddlewareBuilder) -> Self
Converts to this type from the input type.
Source§impl<State: Clone + Send + Sync + 'static> Middleware<State> for CompressMiddleware
impl<State: Clone + Send + Sync + 'static> Middleware<State> for CompressMiddleware
Source§fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
req: Request<State>,
next: Next<'life1, State>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
req: Request<State>,
next: Next<'life1, State>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Asynchronously handle the request, and return a response.
Auto Trait Implementations§
impl Freeze for CompressMiddleware
impl RefUnwindSafe for CompressMiddleware
impl Send for CompressMiddleware
impl Sync for CompressMiddleware
impl Unpin for CompressMiddleware
impl UnsafeUnpin for CompressMiddleware
impl UnwindSafe for CompressMiddleware
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