pub struct CorsConfig {
pub allowed_origins: Vec<String>,
pub allowed_methods: Vec<Method>,
pub allowed_headers: Vec<String>,
pub exposed_headers: Vec<String>,
pub allow_credentials: bool,
pub max_age: Option<u64>,
}Expand description
Configuration for Cross-Origin Resource Sharing (CORS).
Fields§
§allowed_origins: Vec<String>Allowed origins. Use ["*"] to allow all.
allowed_methods: Vec<Method>Allowed HTTP methods.
allowed_headers: Vec<String>Allowed request headers.
exposed_headers: Vec<String>Headers exposed to the client.
allow_credentials: boolWhether to allow credentials (cookies, auth headers).
max_age: Option<u64>Max age for preflight cache (in seconds).
Implementations§
Source§impl CorsConfig
impl CorsConfig
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create a permissive CORS config (allow all origins, common methods).
Sourcepub fn with_origins(origins: Vec<String>) -> Self
pub fn with_origins(origins: Vec<String>) -> Self
Create a CORS config that allows specific origins.
Sourcepub fn apply_headers(&self, headers: &mut HeaderMap, origin: Option<&str>)
pub fn apply_headers(&self, headers: &mut HeaderMap, origin: Option<&str>)
Apply CORS headers to a response.
Sourcepub fn preflight_response(
&self,
origin: Option<&str>,
) -> Result<Response<Full<Bytes>>, OxiHttpError>
pub fn preflight_response( &self, origin: Option<&str>, ) -> Result<Response<Full<Bytes>>, OxiHttpError>
Handle a preflight (OPTIONS) request, returning a 204 No Content response with appropriate CORS 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 (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