pub trait Middleware: Send {
    // Required methods
    fn is_method_get_head(&self) -> bool;
    fn policy(&self, response: &HttpResponse) -> Result<CachePolicy>;
    fn policy_with_options(
        &self,
        response: &HttpResponse,
        options: CacheOptions
    ) -> Result<CachePolicy>;
    fn update_headers(&mut self, parts: &Parts) -> Result<()>;
    fn force_no_cache(&mut self) -> Result<()>;
    fn parts(&self) -> Result<Parts>;
    fn url(&self) -> Result<Url>;
    fn method(&self) -> Result<String>;
    fn remote_fetch<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn overridden_cache_mode(&self) -> Option<CacheMode> { ... }
}
Expand description

Describes the functionality required for interfacing with HTTP client middleware

Required Methods§

source

fn is_method_get_head(&self) -> bool

Determines if the request method is either GET or HEAD

source

fn policy(&self, response: &HttpResponse) -> Result<CachePolicy>

Returns a new cache policy with default options

source

fn policy_with_options( &self, response: &HttpResponse, options: CacheOptions ) -> Result<CachePolicy>

Returns a new cache policy with custom options

source

fn update_headers(&mut self, parts: &Parts) -> Result<()>

Attempts to update the request headers with the passed http::request::Parts

source

fn force_no_cache(&mut self) -> Result<()>

Attempts to force the “no-cache” directive on the request

source

fn parts(&self) -> Result<Parts>

Attempts to construct http::request::Parts from the request

source

fn url(&self) -> Result<Url>

Attempts to determine the requested url

source

fn method(&self) -> Result<String>

Attempts to determine the request method

source

fn remote_fetch<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<HttpResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempts to fetch an upstream resource and return an HttpResponse

Provided Methods§

source

fn overridden_cache_mode(&self) -> Option<CacheMode>

Allows the cache mode to be overridden.

This overrides any cache mode set in the configuration, including cache_mode_fn.

Implementors§