pub struct CacheMiddleware<B, C, CM> { /* private fields */ }Expand description
Cache middleware for reqwest-middleware.
This middleware intercepts HTTP requests and responses, caching them according to the configured policy and predicates.
Use CacheMiddleware::builder() to construct an instance.
See the crate-level documentation for usage examples.
Implementations§
Source§impl<B, C, CM> CacheMiddleware<B, C, CM>
impl<B, C, CM> CacheMiddleware<B, C, CM>
Sourcepub fn new(
backend: Arc<B>,
configuration: C,
concurrency_manager: CM,
cache_status_header: HeaderName,
) -> Self
pub fn new( backend: Arc<B>, configuration: C, concurrency_manager: CM, cache_status_header: HeaderName, ) -> Self
Creates a new cache middleware with explicit components.
For most use cases, prefer CacheMiddleware::builder() which provides
a more ergonomic API with sensible defaults.
Source§impl CacheMiddleware<NotSet, NotSet, NoopConcurrencyManager>
impl CacheMiddleware<NotSet, NotSet, NoopConcurrencyManager>
Sourcepub fn builder() -> CacheMiddlewareBuilder<NotSet, NotSet, NoopConcurrencyManager>
pub fn builder() -> CacheMiddlewareBuilder<NotSet, NotSet, NoopConcurrencyManager>
Creates a new builder for constructing cache middleware.
Both backend() and
config() must be called
before build().
See the crate-level documentation for usage examples.
Trait Implementations§
Source§impl<B, C, CM> Clone for CacheMiddleware<B, C, CM>
impl<B, C, CM> Clone for CacheMiddleware<B, C, CM>
Source§impl<B, C, CM> Middleware for CacheMiddleware<B, C, CM>where
B: CacheBackend + Send + Sync + 'static,
C: CacheConfig<CacheableHttpRequest<Body>, CacheableHttpResponse<Body>> + Clone + Send + Sync + 'static,
C::RequestPredicate: Clone + Send + Sync + 'static,
C::ResponsePredicate: Clone + Send + Sync + 'static,
C::Extractor: Clone + Send + Sync + 'static,
CM: ConcurrencyManager<Result<CacheableHttpResponse<Body>>> + Clone + Send + Sync + 'static,
impl<B, C, CM> Middleware for CacheMiddleware<B, C, CM>where
B: CacheBackend + Send + Sync + 'static,
C: CacheConfig<CacheableHttpRequest<Body>, CacheableHttpResponse<Body>> + Clone + Send + Sync + 'static,
C::RequestPredicate: Clone + Send + Sync + 'static,
C::ResponsePredicate: Clone + Send + Sync + 'static,
C::Extractor: Clone + Send + Sync + 'static,
CM: ConcurrencyManager<Result<CacheableHttpResponse<Body>>> + Clone + Send + Sync + 'static,
Source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: Request,
extensions: &'life1 mut Extensions,
next: Next<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: Request,
extensions: &'life1 mut Extensions,
next: Next<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Invoked with a request before sending it. If you want to continue processing the request,
you should explicitly call
next.run(req, extensions). Read moreAuto Trait Implementations§
impl<B, C, CM> !Freeze for CacheMiddleware<B, C, CM>
impl<B, C, CM> RefUnwindSafe for CacheMiddleware<B, C, CM>
impl<B, C, CM> Send for CacheMiddleware<B, C, CM>
impl<B, C, CM> Sync for CacheMiddleware<B, C, CM>
impl<B, C, CM> Unpin for CacheMiddleware<B, C, CM>
impl<B, C, CM> UnwindSafe for CacheMiddleware<B, C, CM>
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