Struct static_web_server::cors::Cors
source · pub struct Cors { /* private fields */ }Expand description
It defines CORS instance.
Implementations§
source§impl Cors
impl Cors
sourcepub fn allow_methods<I>(self, methods: I) -> Selfwhere
I: IntoIterator,
Method: TryFrom<I::Item>,
pub fn allow_methods<I>(self, methods: I) -> Selfwhere I: IntoIterator, Method: TryFrom<I::Item>,
Adds multiple methods to the existing list of allowed request methods.
Panics
Panics if the provided argument is not a valid http::Method.
sourcepub fn allow_any_origin(self) -> Self
pub fn allow_any_origin(self) -> Self
Sets that any Origin header is allowed.
Warning
This can allow websites you didn’t intend to access this resource, it is usually better to set an explicit list.
sourcepub fn allow_origins<I>(self, origins: I) -> Selfwhere
I: IntoIterator,
I::Item: IntoOrigin,
pub fn allow_origins<I>(self, origins: I) -> Selfwhere I: IntoIterator, I::Item: IntoOrigin,
Add multiple origins to the existing list of allowed Origins.
Panics
Panics if the provided argument is not a valid Origin.
sourcepub fn allow_headers<I>(self, headers: I) -> Selfwhere
I: IntoIterator,
HeaderName: TryFrom<I::Item>,
pub fn allow_headers<I>(self, headers: I) -> Selfwhere I: IntoIterator, HeaderName: TryFrom<I::Item>,
Adds multiple headers to the list of allowed request headers.
Note: These should match the values the browser sends via Access-Control-Request-Headers, e.g.content-type.
Panics
Panics if any of the headers are not a valid http::header::HeaderName.
sourcepub fn expose_headers<I>(self, headers: I) -> Selfwhere
I: IntoIterator,
HeaderName: TryFrom<I::Item>,
pub fn expose_headers<I>(self, headers: I) -> Selfwhere I: IntoIterator, HeaderName: TryFrom<I::Item>,
Adds multiple headers to the list of exposed request headers.
Note: These should match the values the browser sends via Access-Control-Request-Headers, e.g.content-type.
Panics
Panics if any of the headers are not a valid http::header::HeaderName.