pub trait RequestBuilderExt: Sized {
// Required methods
fn with_request_id(self, id: impl AsRef<str>) -> Self;
fn with_idempotency_key(self, key: impl AsRef<str>) -> Self;
fn with_bearer_token(self, token: impl AsRef<str>) -> Self;
}Expand description
Extension methods for reqwest::RequestBuilder.
Required Methods§
Sourcefn with_request_id(self, id: impl AsRef<str>) -> Self
fn with_request_id(self, id: impl AsRef<str>) -> Self
Attach an X-Request-Id header.
§Example
use api_bones_reqwest::RequestBuilderExt;
let _builder = reqwest::Client::new()
.get("https://api.example.com/")
.with_request_id("req-001");Sourcefn with_idempotency_key(self, key: impl AsRef<str>) -> Self
fn with_idempotency_key(self, key: impl AsRef<str>) -> Self
Attach an Idempotency-Key header.
§Example
use api_bones_reqwest::RequestBuilderExt;
let _builder = reqwest::Client::new()
.post("https://api.example.com/orders")
.with_idempotency_key("key-unique-123");Sourcefn with_bearer_token(self, token: impl AsRef<str>) -> Self
fn with_bearer_token(self, token: impl AsRef<str>) -> Self
Attach a Authorization: Bearer <token> header.
§Example
use api_bones_reqwest::RequestBuilderExt;
let _builder = reqwest::Client::new()
.get("https://api.example.com/protected")
.with_bearer_token("my.jwt.token");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.