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(
&mut self,
) -> impl Future<Output = Result<HttpResponse>> + Send;
// Provided method
fn overridden_cache_mode(&self) -> Option<CacheMode> { ... }
}Expand description
Describes the functionality required for interfacing with HTTP client middleware
Required Methods§
Sourcefn is_method_get_head(&self) -> bool
fn is_method_get_head(&self) -> bool
Determines if the request method is either GET or HEAD
Sourcefn policy(&self, response: &HttpResponse) -> Result<CachePolicy>
fn policy(&self, response: &HttpResponse) -> Result<CachePolicy>
Returns a new cache policy with default options
Sourcefn policy_with_options(
&self,
response: &HttpResponse,
options: CacheOptions,
) -> Result<CachePolicy>
fn policy_with_options( &self, response: &HttpResponse, options: CacheOptions, ) -> Result<CachePolicy>
Returns a new cache policy with custom options
Sourcefn update_headers(&mut self, parts: &Parts) -> Result<()>
fn update_headers(&mut self, parts: &Parts) -> Result<()>
Attempts to update the request headers with the passed http::request::Parts
Sourcefn force_no_cache(&mut self) -> Result<()>
fn force_no_cache(&mut self) -> Result<()>
Attempts to force the “no-cache” directive on the request
Sourcefn remote_fetch(&mut self) -> impl Future<Output = Result<HttpResponse>> + Send
fn remote_fetch(&mut self) -> impl Future<Output = Result<HttpResponse>> + Send
Attempts to fetch an upstream resource and return an HttpResponse
Provided Methods§
Sourcefn overridden_cache_mode(&self) -> Option<CacheMode>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.