Struct Cors
pub struct Cors<S> { /* private fields */ }
Expand description
Middleware which adds headers for CORS.
See the module docs for an example.
Implementations§
§impl<S> Cors<S>
impl<S> Cors<S>
pub fn new(inner: S) -> Cors<S>
pub fn new(inner: S) -> Cors<S>
Create a new Cors
.
See CorsLayer::new
for more details.
pub fn permissive(inner: S) -> Cors<S>
pub fn permissive(inner: S) -> Cors<S>
A permissive configuration.
See CorsLayer::permissive
for more details.
pub fn very_permissive(inner: S) -> Cors<S>
pub fn very_permissive(inner: S) -> Cors<S>
A very permissive configuration.
See CorsLayer::very_permissive
for more details.
pub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Consumes self
, returning the underlying service.
pub fn allow_credentials<T>(self, allow_credentials: T) -> Cors<S>where
T: Into<AllowCredentials>,
pub fn allow_credentials<T>(self, allow_credentials: T) -> Cors<S>where
T: Into<AllowCredentials>,
Set the Access-Control-Allow-Credentials
header.
See CorsLayer::allow_credentials
for more details.
pub fn allow_headers<T>(self, headers: T) -> Cors<S>where
T: Into<AllowHeaders>,
pub fn allow_headers<T>(self, headers: T) -> Cors<S>where
T: Into<AllowHeaders>,
Set the value of the Access-Control-Allow-Headers
header.
See CorsLayer::allow_headers
for more details.
pub fn max_age<T>(self, max_age: T) -> Cors<S>
pub fn max_age<T>(self, max_age: T) -> Cors<S>
Set the value of the Access-Control-Max-Age
header.
See CorsLayer::max_age
for more details.
pub fn allow_methods<T>(self, methods: T) -> Cors<S>where
T: Into<AllowMethods>,
pub fn allow_methods<T>(self, methods: T) -> Cors<S>where
T: Into<AllowMethods>,
Set the value of the Access-Control-Allow-Methods
header.
See CorsLayer::allow_methods
for more details.
pub fn allow_origin<T>(self, origin: T) -> Cors<S>where
T: Into<AllowOrigin>,
pub fn allow_origin<T>(self, origin: T) -> Cors<S>where
T: Into<AllowOrigin>,
Set the value of the Access-Control-Allow-Origin
header.
See CorsLayer::allow_origin
for more details.
pub fn expose_headers<T>(self, headers: T) -> Cors<S>where
T: Into<ExposeHeaders>,
pub fn expose_headers<T>(self, headers: T) -> Cors<S>where
T: Into<ExposeHeaders>,
Set the value of the Access-Control-Expose-Headers
header.
See CorsLayer::expose_headers
for more details.
pub fn allow_private_network<T>(self, allow_private_network: T) -> Cors<S>where
T: Into<AllowPrivateNetwork>,
pub fn allow_private_network<T>(self, allow_private_network: T) -> Cors<S>where
T: Into<AllowPrivateNetwork>,
Set the value of the Access-Control-Allow-Private-Network
header.
See CorsLayer::allow_private_network
for more details.
Trait Implementations§
§impl<S, ReqBody, ResBody> Service<Request<ReqBody>> for Cors<S>
impl<S, ReqBody, ResBody> Service<Request<ReqBody>> for Cors<S>
§type Response = <S as Service<Request<ReqBody>>>::Response
type Response = <S as Service<Request<ReqBody>>>::Response
§async fn serve(
&self,
ctx: Context,
req: Request<ReqBody>,
) -> Result<<Cors<S> as Service<Request<ReqBody>>>::Response, <Cors<S> as Service<Request<ReqBody>>>::Error>
async fn serve( &self, ctx: Context, req: Request<ReqBody>, ) -> Result<<Cors<S> as Service<Request<ReqBody>>>::Response, <Cors<S> as Service<Request<ReqBody>>>::Error>
§fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>
fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>
Auto Trait Implementations§
impl<S> !Freeze for Cors<S>
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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<S, Request, Connection> ConnectorService<Request> for S
impl<S, Request, Connection> ConnectorService<Request> for S
§type Connection = Connection
type Connection = Connection
ConnectorService
§fn connect(
&self,
ctx: Context,
req: Request,
) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Request>>::Connection, Request>, <S as ConnectorService<Request>>::Error>> + Send
fn connect( &self, ctx: Context, req: Request, ) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Request>>::Connection, Request>, <S as ConnectorService<Request>>::Error>> + Send
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<S, Body> HttpClientExt for S
impl<S, Body> HttpClientExt for S
§type ExecuteResponse = Response<Body>
type ExecuteResponse = Response<Body>
execute
method.§type ExecuteError = <S as Service<Request<Body>>>::Error
type ExecuteError = <S as Service<Request<Body>>>::Error
execute
method.§fn get(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn get( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
GET
request to a URL. Read more§fn post(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn post( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
POST
request to a URL. Read more§fn put(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn put( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
PUT
request to a URL. Read more§fn patch(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn patch( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
PATCH
request to a URL. Read more§fn delete(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn delete( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
DELETE
request to a URL. Read more§fn head(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn head( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
HEAD
request to a URL. Read more§fn connect(
&self,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn connect( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
CONNECT
request to a URL. Read more§fn request(
&self,
method: Method,
url: impl IntoUrl,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn request( &self, method: Method, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
§fn build_from_request<RequestBody>(
&self,
request: Request<RequestBody>,
) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
fn build_from_request<RequestBody>( &self, request: Request<RequestBody>, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
§fn execute(
&self,
ctx: Context,
request: Request<Body>,
) -> impl Future<Output = Result<<S as HttpClientExt>::ExecuteResponse, <S as HttpClientExt>::ExecuteError>>
fn execute( &self, ctx: Context, request: Request<Body>, ) -> impl Future<Output = Result<<S as HttpClientExt>::ExecuteResponse, <S as HttpClientExt>::ExecuteError>>
Request
. Read more§impl<S, Body> HttpClientWebSocketExt<Body> for S
impl<S, Body> HttpClientWebSocketExt<Body> for S
§fn websocket(
&self,
url: impl IntoUrl,
) -> WebSocketRequestBuilder<WithService<'_, S, Body>>
fn websocket( &self, url: impl IntoUrl, ) -> WebSocketRequestBuilder<WithService<'_, S, Body>>
WebSocketRequestBuilder
] to be used to establish a WebSocket connection over http/1.1.§fn websocket_h2(
&self,
url: impl IntoUrl,
) -> WebSocketRequestBuilder<WithService<'_, S, Body>>
fn websocket_h2( &self, url: impl IntoUrl, ) -> WebSocketRequestBuilder<WithService<'_, S, Body>>
WebSocketRequestBuilder
to be used to establish a WebSocket connection over h2.§fn websocket_with_request<RequestBody>(
&self,
req: Request<RequestBody>,
) -> WebSocketRequestBuilder<WithService<'_, S, Body>>
fn websocket_with_request<RequestBody>( &self, req: Request<RequestBody>, ) -> WebSocketRequestBuilder<WithService<'_, S, Body>>
WebSocketRequestBuilder
starting from the given request. Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<S, R> IntoEndpointService<(R,)> for Swhere
S: Service<Request<Body>, Response = R, Error = Infallible>,
R: IntoResponse + Send + Sync + 'static,
impl<S, R> IntoEndpointService<(R,)> for Swhere
S: Service<Request<Body>, Response = R, Error = Infallible>,
R: IntoResponse + Send + Sync + 'static,
§fn into_endpoint_service(
self,
) -> impl Service<Request<Body>, Response = Response<Body>, Error = Infallible>
fn into_endpoint_service( self, ) -> impl Service<Request<Body>, Response = Response<Body>, Error = Infallible>
rama_core::Service
.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more