Skip to main content

OnRequest

Trait OnRequest 

Source
pub trait OnRequest:
    Debug
    + Send
    + Sync {
    // Required method
    fn on_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        context: &'life1 mut Context<'_>,
        request: &'life2 mut Request,
        authorizer: &'life3 dyn Authorizer,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Callback BearerTokenAuthorizationPolicy invokes on every request it receives, before sending the request.

Required Methods§

Source

fn on_request<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, context: &'life1 mut Context<'_>, request: &'life2 mut Request, authorizer: &'life3 dyn Authorizer, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Invoked once on every BearerTokenAuthorizationPolicy::send invocation, before the policy sends the request.

send doesn’t call this method before retrying a request after an authentication challenge (see OnChallenge for more about challenge handling). Implementations are responsible for authorizing each request via the provided Authorizer. The policy sends the request when this method returns Ok.

§Arguments
  • context - The request context
  • request - The HTTP request being sent
  • authorizer - Helper used to acquire an access token and set the request’s authorization header

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§