pub struct Builder { /* private fields */ }
Expand description
A constructed via warp::cors()
.
Implementations
sourceimpl Builder
impl Builder
sourcepub fn allow_credentials(self, allow: bool) -> Self
pub fn allow_credentials(self, allow: bool) -> Self
Sets whether to add the Access-Control-Allow-Credentials
header.
sourcepub fn allow_method<M>(self, method: M) -> Self where
Method: TryFrom<M>,
pub fn allow_method<M>(self, method: M) -> Self where
Method: TryFrom<M>,
Adds a method to the existing list of allowed request methods.
Panics
Panics if the provided argument is not a valid http::Method
.
sourcepub fn allow_methods<I>(self, methods: I) -> Self where
I: IntoIterator,
Method: TryFrom<I::Item>,
pub fn allow_methods<I>(self, methods: I) -> Self where
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_header<H>(self, header: H) -> Self where
HeaderName: TryFrom<H>,
pub fn allow_header<H>(self, header: H) -> Self where
HeaderName: TryFrom<H>,
Adds a header 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 the provided argument is not a valid http::header::HeaderName
.
sourcepub fn allow_headers<I>(self, headers: I) -> Self where
I: IntoIterator,
HeaderName: TryFrom<I::Item>,
pub fn allow_headers<I>(self, headers: I) -> Self where
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_header<H>(self, header: H) -> Self where
HeaderName: TryFrom<H>,
pub fn expose_header<H>(self, header: H) -> Self where
HeaderName: TryFrom<H>,
Adds a header to the list of exposed headers.
Panics
Panics if the provided argument is not a valid http::header::HeaderName
.
sourcepub fn expose_headers<I>(self, headers: I) -> Self where
I: IntoIterator,
HeaderName: TryFrom<I::Item>,
pub fn expose_headers<I>(self, headers: I) -> Self where
I: IntoIterator,
HeaderName: TryFrom<I::Item>,
Adds multiple headers to the list of exposed headers.
Panics
Panics if any of the headers are not a valid http::header::HeaderName
.
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_origin(self, origin: impl IntoOrigin) -> Self
pub fn allow_origin(self, origin: impl IntoOrigin) -> Self
Add an origin to the existing list of allowed Origin
s.
Panics
Panics if the provided argument is not a valid Origin
.
sourcepub fn allow_origins<I>(self, origins: I) -> Self where
I: IntoIterator,
I::Item: IntoOrigin,
pub fn allow_origins<I>(self, origins: I) -> Self where
I: IntoIterator,
I::Item: IntoOrigin,
Add multiple origins to the existing list of allowed Origin
s.
Panics
Panics if the provided argument is not a valid Origin
.
sourcepub fn max_age(self, seconds: impl Seconds) -> Self
pub fn max_age(self, seconds: impl Seconds) -> Self
Sets the Access-Control-Max-Age
header.
Example
use std::time::Duration;
use warp::Filter;
let cors = warp::cors()
.max_age(30) // 30u32 seconds
.max_age(Duration::from_secs(30)); // or a Duration
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more