pub struct Cors { /* private fields */ }Expand description
CORS middleware.
Implementations§
Source§impl Cors
impl Cors
Sourcepub fn config(self, config: CorsConfig) -> Self
pub fn config(self, config: CorsConfig) -> Self
Replace the configuration entirely.
Sourcepub fn allow_any_origin(self) -> Self
pub fn allow_any_origin(self) -> Self
Allow any origin.
Sourcepub fn allow_origin(self, origin: impl Into<String>) -> Self
pub fn allow_origin(self, origin: impl Into<String>) -> Self
Allow a single exact origin.
Sourcepub fn allow_origin_wildcard(self, pattern: impl Into<String>) -> Self
pub fn allow_origin_wildcard(self, pattern: impl Into<String>) -> Self
Allow a wildcard origin pattern (supports *).
Sourcepub fn allow_origin_regex(self, pattern: impl Into<String>) -> Self
pub fn allow_origin_regex(self, pattern: impl Into<String>) -> Self
Allow a simple regex origin pattern (supports ^, $, ., *).
Sourcepub fn allow_credentials(self, allow: bool) -> Self
pub fn allow_credentials(self, allow: bool) -> Self
Allow credentials for CORS responses.
Sourcepub fn allow_methods<I>(self, methods: I) -> Selfwhere
I: IntoIterator<Item = Method>,
pub fn allow_methods<I>(self, methods: I) -> Selfwhere
I: IntoIterator<Item = Method>,
Override allowed HTTP methods for preflight.
Sourcepub fn allow_headers<I, S>(self, headers: I) -> Self
pub fn allow_headers<I, S>(self, headers: I) -> Self
Override allowed headers for preflight.
Sourcepub fn expose_headers<I, S>(self, headers: I) -> Self
pub fn expose_headers<I, S>(self, headers: I) -> Self
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,
) -> BoxFuture<'a, ControlFlow>
fn before<'a>( &'a self, _ctx: &'a RequestContext, req: &'a mut Request, ) -> BoxFuture<'a, ControlFlow>
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 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).