pub struct CorsConfig {
pub allowed_origins: Vec<String>,
pub allowed_methods: Vec<String>,
pub allowed_headers: Vec<String>,
pub max_age_secs: u64,
pub allow_credentials: bool,
}Expand description
Cross-Origin Resource Sharing (CORS) policy configuration.
Used to generate Access-Control-* headers for preflight and main requests.
Fields§
§allowed_origins: Vec<String>Allowed origins. Use ["*"] to permit all origins.
allowed_methods: Vec<String>Allowed HTTP methods.
allowed_headers: Vec<String>Allowed request headers.
max_age_secs: u64Access-Control-Max-Age in seconds (how long browsers may cache the preflight).
allow_credentials: boolWhether to allow credentials (cookies, auth headers).
Implementations§
Source§impl CorsConfig
impl CorsConfig
Sourcepub fn is_origin_allowed(&self, origin: &str) -> bool
pub fn is_origin_allowed(&self, origin: &str) -> bool
Returns true if the given origin is permitted by this policy.
An entry of "*" in allowed_origins permits all origins.
Sourcepub fn access_control_headers(&self) -> Vec<(String, String)>
pub fn access_control_headers(&self) -> Vec<(String, String)>
Generate Access-Control-* response headers as (name, value) pairs.
Returns headers suitable for both preflight (OPTIONS) and actual responses.
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 (const: unstable) · 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 UnsafeUnpin 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