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) -> 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.
Trait Implementations§
source§impl<S, ReqBody, ResBody> Service<Request<ReqBody>> for Cors<S>where
S: Service<Request<ReqBody>, Response = Response<ResBody>>,
ResBody: Default,
impl<S, ReqBody, ResBody> Service<Request<ReqBody>> for Cors<S>where
S: Service<Request<ReqBody>, Response = Response<ResBody>>,
ResBody: Default,
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> 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<M, S, Target, Request> MakeService<Target, Request> for Mwhere
M: Service<Target, Response = S>,
S: Service<Request>,
impl<M, S, Target, Request> MakeService<Target, Request> for Mwhere
M: Service<Target, Response = S>,
S: Service<Request>,
source§fn poll_ready(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
fn poll_ready(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
Poll::Ready
when the factory is able to create more services. Read moresource§fn make_service(
&mut self,
target: Target
) -> <M as MakeService<Target, Request>>::Future
fn make_service(
&mut self,
target: Target
) -> <M as MakeService<Target, Request>>::Future
source§fn into_service(self) -> IntoService<Self, Request>where
Self: Sized,
fn into_service(self) -> IntoService<Self, Request>where
Self: Sized,
source§fn as_service(&mut self) -> AsService<'_, Self, Request>where
Self: Sized,
fn as_service(&mut self) -> AsService<'_, Self, Request>where
Self: Sized,
source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
source§impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
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 call_all<S>(self, reqs: S) -> CallAll<Self, S>where
Self: Sized,
Self::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
S: Stream<Item = Request>,
fn call_all<S>(self, reqs: S) -> CallAll<Self, S>where
Self: Sized,
Self::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
S: Stream<Item = Request>,
source§fn and_then<F>(self, f: F) -> AndThen<Self, F>where
Self: Sized,
F: Clone,
fn and_then<F>(self, f: F) -> AndThen<Self, F>where
Self: Sized,
F: Clone,
poll_ready
method. Read moresource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>where
Self: Sized,
F: FnOnce(Self::Response) -> Response + Clone,
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>where
Self: Sized,
F: FnOnce(Self::Response) -> Response + Clone,
poll_ready
method. Read moresource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>where
Self: Sized,
F: FnOnce(Self::Error) -> Error + Clone,
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>where
Self: Sized,
F: FnOnce(Self::Error) -> Error + Clone,
poll_ready
method. Read moresource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>where
Self: Sized,
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>where
Self: Sized,
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,
Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more