Skip to main content

Middleware

Trait Middleware 

Source
pub trait Middleware: Send {
    // Required methods
    fn is_method_get_head(&self) -> bool;
    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 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§

Source

fn is_method_get_head(&self) -> bool

Determines if the request method is either GET or HEAD

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 remote_fetch(&mut self) -> impl Future<Output = Result<HttpResponse>> + Send

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§