pub struct Cors { /* private fields */ }Expand description
CORS middleware.
Implementations§
Source§impl Cors
impl Cors
Sourcepub fn config(self, config: CorsConfig) -> Cors
pub fn config(self, config: CorsConfig) -> Cors
Replace the configuration entirely.
Sourcepub fn allow_any_origin(self) -> Cors
pub fn allow_any_origin(self) -> Cors
Allow any origin.
Sourcepub fn allow_origin(self, origin: impl Into<String>) -> Cors
pub fn allow_origin(self, origin: impl Into<String>) -> Cors
Allow a single exact origin.
Sourcepub fn allow_origin_wildcard(self, pattern: impl Into<String>) -> Cors
pub fn allow_origin_wildcard(self, pattern: impl Into<String>) -> Cors
Allow a wildcard origin pattern (supports *).
Sourcepub fn allow_origin_regex(self, pattern: impl Into<String>) -> Cors
pub fn allow_origin_regex(self, pattern: impl Into<String>) -> Cors
Allow a simple regex origin pattern (supports ^, $, ., *).
Sourcepub fn allow_credentials(self, allow: bool) -> Cors
pub fn allow_credentials(self, allow: bool) -> Cors
Allow credentials for CORS responses.
Sourcepub fn allow_methods<I>(self, methods: I) -> Corswhere
I: IntoIterator<Item = Method>,
pub fn allow_methods<I>(self, methods: I) -> Corswhere
I: IntoIterator<Item = Method>,
Override allowed HTTP methods for preflight.
Sourcepub fn allow_headers<I, S>(self, headers: I) -> Cors
pub fn allow_headers<I, S>(self, headers: I) -> Cors
Override allowed headers for preflight.
Sourcepub fn expose_headers<I, S>(self, headers: I) -> Cors
pub fn expose_headers<I, S>(self, headers: I) -> Cors
Add exposed headers for responses.
Trait Implementations§
Source§impl Middleware for Cors
impl Middleware for Cors
Source§fn before<'a>(
&'a self,
_ctx: &'a RequestContext,
req: &'a mut Request,
) -> Pin<Box<dyn Future<Output = ControlFlow> + Send + 'a>>
fn before<'a>( &'a self, _ctx: &'a RequestContext, req: &'a mut Request, ) -> Pin<Box<dyn Future<Output = ControlFlow> + Send + 'a>>
Called before the handler executes. Read more
Auto Trait Implementations§
impl Freeze for Cors
impl RefUnwindSafe for Cors
impl Send for Cors
impl Sync for Cors
impl Unpin for Cors
impl UnsafeUnpin for Cors
impl UnwindSafe for Cors
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).