pub struct HttpOptions {
pub request_timeout: Duration,
pub body_size_limit: usize,
pub concurrency_limit: usize,
pub allow_credentials: bool,
/* private fields */
}Expand description
Configuration for the shared HTTP layer stack.
CORS denies cross-origin access until explicit origins are supplied through
HttpOptions::with_allowed_origins. Wildcard origins are rejected, which
also prevents the invalid wildcard-with-credentials combination.
Fields§
§request_timeout: DurationMaximum time allowed for one request, including concurrency queueing.
body_size_limit: usizeMaximum accepted request body size in bytes.
concurrency_limit: usizeMaximum number of requests processed concurrently.
allow_credentials: boolWhether browsers may send credentials to explicitly allowed origins.
Implementations§
Source§impl HttpOptions
impl HttpOptions
Sourcepub fn with_allowed_origins<I, S>(
self,
origins: I,
) -> Result<Self, HttpOptionsError>
pub fn with_allowed_origins<I, S>( self, origins: I, ) -> Result<Self, HttpOptionsError>
Replaces the CORS origin allowlist.
Each origin must be a valid HTTP header value and must not be *.
Sourcepub fn allowed_origins(&self) -> &[HeaderValue]
pub fn allowed_origins(&self) -> &[HeaderValue]
Returns the explicit CORS origin allowlist.
Sourcepub fn with_additional_allowed_headers<I, S>(
self,
headers: I,
) -> Result<Self, HttpOptionsError>
pub fn with_additional_allowed_headers<I, S>( self, headers: I, ) -> Result<Self, HttpOptionsError>
Adds request headers to the standard CORS allowlist.
The built-in Authorization, Content-Type, x-request-id,
traceparent, and tracestate headers remain allowed. Duplicate header
names are ignored.
Sourcepub fn additional_allowed_headers(&self) -> &[HeaderName]
pub fn additional_allowed_headers(&self) -> &[HeaderName]
Returns the request headers added to the standard CORS allowlist.
Sourcepub fn with_json_rejection_code(
self,
code: impl Into<String>,
) -> Result<Self, HttpOptionsError>
pub fn with_json_rejection_code( self, code: impl Into<String>, ) -> Result<Self, HttpOptionsError>
Overrides the error code returned when crate::ApiJson rejects a body.
The default is validation_failed. The replacement must be a non-empty
snake_case identifier.
Sourcepub fn json_rejection_code(&self) -> &str
pub fn json_rejection_code(&self) -> &str
Returns the error code used for JSON extractor rejections.
Sourcepub fn from_config(config: &HttpConfig) -> Result<Self, HttpOptionsError>
pub fn from_config(config: &HttpConfig) -> Result<Self, HttpOptionsError>
Builds options from Baukit’s standard public-listener configuration.
Listener address and port are intentionally ignored because they belong to runtime composition rather than an Axum layer.
Trait Implementations§
Source§impl Clone for HttpOptions
impl Clone for HttpOptions
Source§fn clone(&self) -> HttpOptions
fn clone(&self) -> HttpOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more