Struct poem::middleware::Cors
source · pub struct Cors { /* private fields */ }
Expand description
Implementations§
source§impl Cors
impl Cors
sourcepub fn allow_credentials(self, allow_credentials: bool) -> Self
pub fn allow_credentials(self, allow_credentials: bool) -> Self
Set allow credentials.
sourcepub fn allow_header<T>(self, header: T) -> Selfwhere
HeaderName: TryFrom<T>,
pub fn allow_header<T>(self, header: T) -> Selfwhere
HeaderName: TryFrom<T>,
Add an allow header.
NOTE: Default is allow any header.
sourcepub fn allow_headers<I, T>(self, headers: I) -> Self
pub fn allow_headers<I, T>(self, headers: I) -> Self
Add many allow headers.
sourcepub fn allow_method<T>(self, method: T) -> Self
pub fn allow_method<T>(self, method: T) -> Self
Add an allow method.
NOTE: Default is allow any method.
sourcepub fn allow_methods<I, T>(self, methods: I) -> Self
pub fn allow_methods<I, T>(self, methods: I) -> Self
Add many allow methods.
sourcepub fn allow_origin<T>(self, origin: T) -> Selfwhere
HeaderValue: TryFrom<T>,
pub fn allow_origin<T>(self, origin: T) -> Selfwhere
HeaderValue: TryFrom<T>,
Add an allow origin.
NOTE: Default is allow any origin.
sourcepub fn allow_origin_regex(self, origin: impl AsRef<str>) -> Self
pub fn allow_origin_regex(self, origin: impl AsRef<str>) -> Self
Add an allowed origin that supports ‘*’ wildcard.
Example: rust cors.allow_origin_regex("https://*.domain.url")
sourcepub fn allow_origins<I, T>(self, origins: I) -> Self
pub fn allow_origins<I, T>(self, origins: I) -> Self
Add many allow origins.
sourcepub fn allow_origins_fn<F>(self, f: F) -> Self
pub fn allow_origins_fn<F>(self, f: F) -> Self
Determinate allowed origins by processing requests which didn’t match
any origins specified in the allow_origin
.
This function will receive the Origin
header, which can be used to
determine whether to allow the request.
sourcepub fn expose_header<T>(self, header: T) -> Selfwhere
HeaderName: TryFrom<T>,
pub fn expose_header<T>(self, header: T) -> Selfwhere
HeaderName: TryFrom<T>,
Add an expose header.
sourcepub fn expose_headers<I, T>(self, headers: I) -> Self
pub fn expose_headers<I, T>(self, headers: I) -> Self
Add many expose headers.
Trait Implementations§
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> TowerCompatExt for T
impl<T> TowerCompatExt for T
source§fn compat<ResBody, Err, Fut>(self) -> TowerCompatEndpoint<Self>where
ResBody: Body + Send + Sync + 'static,
ResBody::Data: Into<Bytes> + Send + 'static,
ResBody::Error: StdError + Send + Sync + 'static,
Err: Into<Error>,
Self: Service<Request<BoxBody<Bytes, Error>>, Response = Response<ResBody>, Error = Err, Future = Fut> + Clone + Send + Sync + Sized + 'static,
Fut: Future<Output = Result<Response<ResBody>, Err>> + Send + 'static,
fn compat<ResBody, Err, Fut>(self) -> TowerCompatEndpoint<Self>where
ResBody: Body + Send + Sync + 'static,
ResBody::Data: Into<Bytes> + Send + 'static,
ResBody::Error: StdError + Send + Sync + 'static,
Err: Into<Error>,
Self: Service<Request<BoxBody<Bytes, Error>>, Response = Response<ResBody>, Error = Err, Future = Fut> + Clone + Send + Sync + Sized + 'static,
Fut: Future<Output = Result<Response<ResBody>, Err>> + Send + 'static,
Available on crate feature
tower-compat
only.Converts a tower service to a poem endpoint.