Trait reqwest_middleware::RequestInitialiser

source ·
pub trait RequestInitialiser:
    'static
    + Send
    + Sync {
    // Required method
    fn init(&self, req: RequestBuilder) -> RequestBuilder;
}
Expand description

When attached to a ClientWithMiddleware (generally using with_init), it is run whenever the client starts building a request, in the order it was attached.

§Example

use reqwest_middleware::{RequestInitialiser, RequestBuilder};

struct AuthInit;

impl RequestInitialiser for AuthInit {
    fn init(&self, req: RequestBuilder) -> RequestBuilder {
        req.bearer_auth("my_auth_token")
    }
}

Required Methods§

Implementors§

source§

impl<F> RequestInitialiser for F
where F: Send + Sync + 'static + Fn(RequestBuilder) -> RequestBuilder,

source§

impl<T: Send + Sync + Clone + 'static> RequestInitialiser for Extension<T>