pub struct RequestOptions { /* private fields */ }Expand description
Per-request transport options applied on top of the operation’s own parameters.
Every generated client method takes a RequestOptions argument, letting you
attach extra HTTP headers or authentication to a single request without
re-instantiating the underlying client. Pass RequestOptions::default
(or RequestOptions::new) when you have nothing to add.
The builder methods are chainable:
let options = openapi_trait::RequestOptions::new()
.bearer_auth("token-123")
.header("X-Request-Id", "abc");Extra headers are applied after the operation’s declared headers, so a
header set here is sent in addition to (and after) any same-named operation
header. Authentication set via bearer_auth or basic_auth, by
contrast, replaces the Authorization header from a configured security
scheme, so per-request credentials deterministically win.
Implementations§
Source§impl RequestOptions
impl RequestOptions
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add an extra header to the request.
Invalid header names or values are surfaced by reqwest when the request
is sent, matching reqwest::RequestBuilder::header semantics.
Sourcepub fn bearer_auth(self, token: impl Into<String>) -> Self
pub fn bearer_auth(self, token: impl Into<String>) -> Self
Attach an Authorization: Bearer <token> header to the request.
This replaces any Authorization header a configured security scheme
would otherwise set, so the per-request token always wins. Calling it
clears any credentials previously set via basic_auth.
Sourcepub fn basic_auth(
self,
username: impl Into<String>,
password: Option<String>,
) -> Self
pub fn basic_auth( self, username: impl Into<String>, password: Option<String>, ) -> Self
Attach Authorization: Basic credentials to the request.
This replaces any Authorization header a configured security scheme
would otherwise set, so the per-request credentials always win. Calling
it clears any token previously set via bearer_auth.
Sourcepub fn apply(self, request: RequestBuilder) -> RequestBuilder
pub fn apply(self, request: RequestBuilder) -> RequestBuilder
Apply these options to a reqwest request builder.
Used by the generated reqwest-backed client implementation; you should not normally need to call it directly.
Trait Implementations§
Source§impl Clone for RequestOptions
impl Clone for RequestOptions
Source§fn clone(&self) -> RequestOptions
fn clone(&self) -> RequestOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more