pub struct CorsConfig {
pub allowed_origins: Vec<String>,
pub allowed_methods: Vec<String>,
pub allowed_headers: Vec<String>,
pub expose_headers: Option<Vec<String>>,
pub max_age: Option<u32>,
pub allow_credentials: Option<bool>,
/* private fields */
}Expand description
CORS configuration for a route
Fields§
§allowed_origins: Vec<String>§allowed_methods: Vec<String>§allowed_headers: Vec<String>§expose_headers: Option<Vec<String>>§max_age: Option<u32>§allow_credentials: Option<bool>Implementations§
Source§impl CorsConfig
impl CorsConfig
Sourcepub fn allowed_methods_joined(&self) -> &str
pub fn allowed_methods_joined(&self) -> &str
Get the cached joined methods string for preflight responses
Sourcepub fn allowed_headers_joined(&self) -> &str
pub fn allowed_headers_joined(&self) -> &str
Get the cached joined headers string for preflight responses
Sourcepub fn is_origin_allowed(&self, origin: &str) -> bool
pub fn is_origin_allowed(&self, origin: &str) -> bool
Check if an origin is allowed (O(1) with wildcard, O(n) for exact match)
Sourcepub fn is_method_allowed(&self, method: &str) -> bool
pub fn is_method_allowed(&self, method: &str) -> bool
Check if a method is allowed (O(1) with wildcard, O(n) for exact match)
Sourcepub fn are_headers_allowed(&self, requested: &[&str]) -> bool
pub fn are_headers_allowed(&self, requested: &[&str]) -> bool
Check if all requested headers are allowed (O(n) where n = num requested headers)
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
Source§impl Default for CorsConfig
impl Default for CorsConfig
Source§impl<'de> Deserialize<'de> for CorsConfig
impl<'de> Deserialize<'de> for CorsConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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