pub struct CorsConfig {
pub allowed_origins: Vec<HeaderValue>,
pub allowed_methods: Vec<Method>,
pub allowed_headers: Vec<HeaderName>,
pub allow_credentials: bool,
pub max_age: u64,
}Expand description
CORS 配置结构体
用于配置跨域资源共享的各项参数。
Fields§
§allowed_origins: Vec<HeaderValue>允许的源列表
allowed_methods: Vec<Method>允许的 HTTP 方法列表
allowed_headers: Vec<HeaderName>允许的请求头列表
allow_credentials: bool是否允许携带凭证
max_age: u64预检请求缓存时间(秒)
Implementations§
Source§impl CorsConfig
impl CorsConfig
Sourcepub fn allow_origin(self, origin: impl Into<String>) -> Self
pub fn allow_origin(self, origin: impl Into<String>) -> Self
Sourcepub fn allow_origins<I, S>(self, origins: I) -> Self
pub fn allow_origins<I, S>(self, origins: I) -> Self
Sourcepub fn allow_method(self, method: impl Into<String>) -> Self
pub fn allow_method(self, method: impl Into<String>) -> Self
Sourcepub fn allow_methods<I, S>(self, methods: I) -> Self
pub fn allow_methods<I, S>(self, methods: I) -> Self
Sourcepub fn allow_header(self, header_name: impl Into<String>) -> Self
pub fn allow_header(self, header_name: impl Into<String>) -> Self
Sourcepub fn allow_headers<I, S>(self, headers: I) -> Self
pub fn allow_headers<I, S>(self, headers: I) -> Self
Sourcepub fn allow_credentials(self, allow: bool) -> Self
pub fn allow_credentials(self, allow: bool) -> Self
Sourcepub fn into_layer(self) -> CorsLayer
pub fn into_layer(self) -> CorsLayer
Trait Implementations§
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