pub struct CorsConfig {
pub allow_all_localhost: bool,
pub allow_credentials: bool,
pub expose_headers: bool,
pub max_age_secs: u64,
pub allowed_methods: Vec<Method>,
pub allowed_headers: Vec<HeaderName>,
}Expand description
CORS configuration options.
Fields§
§allow_all_localhost: boolWhether to allow all localhost origins (default: true)
allow_credentials: boolWhether to allow credentials (cookies, auth headers)
expose_headers: boolWhether to expose response headers to the client
max_age_secs: u64Maximum age for preflight cache in seconds
allowed_methods: Vec<Method>Allowed HTTP methods
allowed_headers: Vec<HeaderName>Allowed request headers
Implementations§
Source§impl CorsConfig
impl CorsConfig
Sourcepub fn with_max_age(self, secs: u64) -> Self
pub fn with_max_age(self, secs: u64) -> Self
Set the maximum age for preflight cache.
Sourcepub fn with_allow_credentials(self, allow: bool) -> Self
pub fn with_allow_credentials(self, allow: bool) -> Self
Enable or disable credentials support.
Sourcepub fn with_expose_headers(self, expose: bool) -> Self
pub fn with_expose_headers(self, expose: bool) -> Self
Enable or disable header exposure.
Sourcepub fn with_methods(self, methods: Vec<Method>) -> Self
pub fn with_methods(self, methods: Vec<Method>) -> Self
Set allowed HTTP methods.
Sourcepub fn with_headers(self, headers: Vec<HeaderName>) -> Self
pub fn with_headers(self, headers: Vec<HeaderName>) -> Self
Set allowed request headers.
Sourcepub fn with_strict_origins(self) -> Self
pub fn with_strict_origins(self) -> Self
Disable localhost origin allowance (for custom origin handling).
Trait Implementations§
Source§impl Clone for CorsConfig
impl Clone for CorsConfig
Source§fn clone(&self) -> CorsConfig
fn clone(&self) -> CorsConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CorsConfig
impl Debug for CorsConfig
Auto Trait Implementations§
impl Freeze for CorsConfig
impl RefUnwindSafe for CorsConfig
impl Send for CorsConfig
impl Sync for CorsConfig
impl Unpin for CorsConfig
impl UnwindSafe for CorsConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more