pub struct CorsConfig {
pub origins: Vec<String>,
pub methods: Vec<String>,
pub headers: Vec<String>,
pub exposed_headers: Vec<String>,
pub credentials: bool,
pub max_age: Option<Duration>,
}Expand description
Cross-Origin Resource Sharing policy. origins empty ⇒ no CORS layer
installed (the default). Lists are comma-separated in env vars.
Fields§
§origins: Vec<String>§methods: Vec<String>§headers: Vec<String>§exposed_headers: Vec<String>§credentials: bool§max_age: Option<Duration>Implementations§
Source§impl CorsConfig
impl CorsConfig
Sourcepub fn from_env(env: &ConfigService) -> Result<Option<Self>>
pub fn from_env(env: &ConfigService) -> Result<Option<Self>>
Build a CorsConfig from the NESTRS_HTTP__CORS_* keys. Returns
Ok(None) when NESTRS_HTTP__CORS_ORIGINS is unset (CORS off).
Sourcepub fn into_middleware(self) -> Result<Cors>
pub fn into_middleware(self) -> Result<Cors>
Translate to poem’s middleware. origins: ["*"] becomes the
wildcard; explicit origins map one-to-one.
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
Source§impl Default for CorsConfig
impl Default for CorsConfig
Source§fn default() -> CorsConfig
fn default() -> CorsConfig
Returns the “default value” for a type. Read more
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
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: 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 as Body>::Data: Into<Bytes> + Send + 'static,
<ResBody as Body>::Error: Error + Send + Sync + 'static,
Err: Into<Error>,
Self: Sized + Service<Request<BoxBody<Bytes, Error>>, Response = Response<ResBody>, Error = Err, Future = Fut> + Clone + Send + Sync + '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 as Body>::Data: Into<Bytes> + Send + 'static,
<ResBody as Body>::Error: Error + Send + Sync + 'static,
Err: Into<Error>,
Self: Sized + Service<Request<BoxBody<Bytes, Error>>, Response = Response<ResBody>, Error = Err, Future = Fut> + Clone + Send + Sync + 'static,
Fut: Future<Output = Result<Response<ResBody>, Err>> + Send + 'static,
Converts a tower service to a poem endpoint.