Struct tower_http::cors::Cors
source · pub struct Cors<S> { /* private fields */ }
Expand description
Middleware which adds headers for CORS.
See the module docs for an example.
Implementations§
source§impl<S> Cors<S>
impl<S> Cors<S>
sourcepub fn new(inner: S) -> Self
pub fn new(inner: S) -> Self
Create a new Cors
.
See CorsLayer::new
for more details.
sourcepub fn permissive(inner: S) -> Self
pub fn permissive(inner: S) -> Self
A permissive configuration.
See CorsLayer::permissive
for more details.
sourcepub fn very_permissive(inner: S) -> Self
pub fn very_permissive(inner: S) -> Self
A very permissive configuration.
See CorsLayer::very_permissive
for more details.
sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Consumes self
, returning the underlying service.
sourcepub fn allow_credentials<T>(self, allow_credentials: T) -> Selfwhere
T: Into<AllowCredentials>,
pub fn allow_credentials<T>(self, allow_credentials: T) -> Selfwhere T: Into<AllowCredentials>,
Set the Access-Control-Allow-Credentials
header.
See CorsLayer::allow_credentials
for more details.
sourcepub fn allow_headers<T>(self, headers: T) -> Selfwhere
T: Into<AllowHeaders>,
pub fn allow_headers<T>(self, headers: T) -> Selfwhere T: Into<AllowHeaders>,
Set the value of the Access-Control-Allow-Headers
header.
See CorsLayer::allow_headers
for more details.
sourcepub fn max_age<T>(self, max_age: T) -> Selfwhere
T: Into<MaxAge>,
pub fn max_age<T>(self, max_age: T) -> Selfwhere T: Into<MaxAge>,
Set the value of the Access-Control-Max-Age
header.
See CorsLayer::max_age
for more details.
sourcepub fn allow_methods<T>(self, methods: T) -> Selfwhere
T: Into<AllowMethods>,
pub fn allow_methods<T>(self, methods: T) -> Selfwhere T: Into<AllowMethods>,
Set the value of the Access-Control-Allow-Methods
header.
See CorsLayer::allow_methods
for more details.
sourcepub fn allow_origin<T>(self, origin: T) -> Selfwhere
T: Into<AllowOrigin>,
pub fn allow_origin<T>(self, origin: T) -> Selfwhere T: Into<AllowOrigin>,
Set the value of the Access-Control-Allow-Origin
header.
See CorsLayer::allow_origin
for more details.
sourcepub fn expose_headers<T>(self, headers: T) -> Selfwhere
T: Into<ExposeHeaders>,
pub fn expose_headers<T>(self, headers: T) -> Selfwhere T: Into<ExposeHeaders>,
Set the value of the Access-Control-Expose-Headers
header.
See CorsLayer::expose_headers
for more details.