pub struct CorsConfig {
pub allowed_origins: Vec<String>,
pub allowed_methods: Vec<String>,
pub allowed_headers: Vec<String>,
pub allow_credentials: bool,
pub max_age: u32,
}Expand description
CORS configuration for the Router
Fields§
§allowed_origins: Vec<String>Allowed origins (e.g., “http://localhost:3000”) Use “*” to allow all origins
allowed_methods: Vec<String>Allowed HTTP methods (e.g., “GET”, “POST”, “PUT”, “DELETE”) Empty means allow all methods
allowed_headers: Vec<String>Allowed HTTP headers (e.g., “Content-Type”, “Authorization”) Empty means allow all headers
allow_credentials: boolWhether to allow credentials (cookies, authorization headers)
max_age: u32Max age for CORS preflight cache (in seconds)
Implementations§
Source§impl CorsConfig
impl CorsConfig
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create a new CORS config that allows everything (useful for development)
Sourcepub fn restrictive() -> Self
pub fn restrictive() -> Self
Create a new CORS config with no allowed origins (restrictive default)
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