pub struct CorsConfig {
pub allowed_origins: Vec<String>,
pub allowed_methods: Vec<String>,
pub allowed_headers: Vec<String>,
pub exposed_headers: Vec<String>,
pub allow_credentials: bool,
pub max_age: u64,
pub enabled: bool,
}Expand description
Configuration for CORS middleware.
Fields§
§allowed_origins: Vec<String>Allowed origins. An empty list means no CORS headers are added.
Use ["*"] to allow all origins (not recommended for production).
allowed_methods: Vec<String>Allowed HTTP methods. Defaults to common auth methods.
allowed_headers: Vec<String>Allowed request headers.
exposed_headers: Vec<String>Headers exposed to the browser.
allow_credentials: boolWhether credentials (cookies, authorization) are allowed.
max_age: u64Max age for preflight cache (seconds).
enabled: boolWhether CORS handling is enabled.
Implementations§
Source§impl CorsConfig
impl CorsConfig
pub fn new() -> CorsConfig
pub fn allowed_origin(self, origin: impl Into<String>) -> CorsConfig
pub fn allow_credentials(self, allow: bool) -> CorsConfig
pub fn max_age(self, seconds: u64) -> CorsConfig
pub fn enabled(self, enabled: bool) -> CorsConfig
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§fn default() -> CorsConfig
fn default() -> CorsConfig
Returns the “default value” for a type. 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 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