Struct tower_http::cors::Cors
source · pub struct Cors<S> { /* private fields */ }
cors
only.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) -> Self
pub fn max_age<T>(self, max_age: T) -> Self
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.
sourcepub fn allow_private_network<T>(self, allow_private_network: T) -> Selfwhere
T: Into<AllowPrivateNetwork>,
pub fn allow_private_network<T>(self, allow_private_network: T) -> Selfwhere
T: Into<AllowPrivateNetwork>,
Set the value of the Access-Control-Allow-Private-Network
header.
See CorsLayer::allow_private_network
for more details.
Trait Implementations§
Auto Trait Implementations§
impl<S> !RefUnwindSafe for Cors<S>
impl<S> Send for Cors<S>where
S: Send,
impl<S> Sync for Cors<S>where
S: Sync,
impl<S> Unpin for Cors<S>where
S: Unpin,
impl<S> !UnwindSafe for Cors<S>
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
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
source§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
source§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
source§fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
ServiceExt::ready
method insteadsource§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service
, calling with the providing request once it is ready.source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready
method. Read moresource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
poll_ready
method. Read moresource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
poll_ready
method. Read moresource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more