#[non_exhaustive]pub struct ApiRequestContextOptions {
pub base_url: Option<String>,
pub user_agent: Option<String>,
pub timeout: Option<Duration>,
pub ignore_https_errors: bool,
pub extra_http_headers: Headers,
}Expand description
Configuration for building an APIRequestContext.
Mirrors the relevant subset of Playwright’s newContext({ baseURL, ... })
options that apply to a standalone API request context. Use Default for
sensible no-op defaults, then chain the builder setters:
let opts = ApiRequestContextOptions::default()
.base_url("https://api.example.com")
.user_agent("my-bot/1.0")
.timeout(Duration::from_secs(30))
.ignore_https_errors(true);See: https://playwright.dev/docs/api/class-apirequestcontext
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.base_url: Option<String>Base URL prepended to any relative request URL (one that does not start
with http:// or https://).
user_agent: Option<String>User-Agent header applied to every request. Per-request headers take
precedence.
timeout: Option<Duration>Default per-request timeout. Overridden by a per-request timeout in
APIRequestOptions.
ignore_https_errors: boolWhen true, the underlying reqwest::Client accepts invalid TLS
certificates (mirrors Playwright’s ignoreHTTPSErrors).
extra_http_headers: HeadersExtra headers merged into every request, below per-request headers.
Implementations§
Source§impl ApiRequestContextOptions
impl ApiRequestContextOptions
Sourcepub fn base_url(self, url: impl Into<String>) -> Self
pub fn base_url(self, url: impl Into<String>) -> Self
Set the base URL prepended to relative request URLs.
Sourcepub fn user_agent(self, ua: impl Into<String>) -> Self
pub fn user_agent(self, ua: impl Into<String>) -> Self
Set the User-Agent header applied to every request.
Sourcepub fn ignore_https_errors(self, ignore: bool) -> Self
pub fn ignore_https_errors(self, ignore: bool) -> Self
When true, accept invalid TLS certificates.
Sourcepub fn extra_http_headers(self, headers: Headers) -> Self
pub fn extra_http_headers(self, headers: Headers) -> Self
Set the extra headers merged into every request (replaces any previously set extras).
Trait Implementations§
Source§impl Clone for ApiRequestContextOptions
impl Clone for ApiRequestContextOptions
Source§fn clone(&self) -> ApiRequestContextOptions
fn clone(&self) -> ApiRequestContextOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more