Skip to main content

HttpClientBuilderExt

Trait HttpClientBuilderExt 

Source
pub trait HttpClientBuilderExt {
    // Required methods
    fn with_bearer_auth(self, token: Token) -> Self;
    fn with_bearer_auth_header(
        self,
        token: Token,
        header_name: HeaderName,
    ) -> Self;
}
Expand description

Extension trait for adding bearer auth to modkit_http::HttpClientBuilder.

§Example

use modkit_auth::HttpClientBuilderExt;

let token = Token::new(config).await?;
let client = HttpClientBuilder::new()
    .with_bearer_auth(token)
    .build()?;

Required Methods§

Source

fn with_bearer_auth(self, token: Token) -> Self

Add Authorization: Bearer <token> injection to the HTTP client.

Source

fn with_bearer_auth_header(self, token: Token, header_name: HeaderName) -> Self

Add <header_name>: Bearer <token> injection to the HTTP client.

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.

Implementations on Foreign Types§

Source§

impl HttpClientBuilderExt for HttpClientBuilder

Source§

fn with_bearer_auth(self, token: Token) -> Self

Source§

fn with_bearer_auth_header(self, token: Token, header_name: HeaderName) -> Self

Implementors§