[][src]Struct salvo_extra::cors::Builder

pub struct Builder { /* fields omitted */ }

A constructed via salvo_extra::cors::cors().

Implementations

impl Builder[src]

pub fn allow_credentials(mut self: Self, allow: bool) -> Self[src]

Sets whether to add the Access-Control-Allow-Credentials header.

pub fn allow_method<M>(mut self: Self, method: M) -> Self where
    Method: TryFrom<M>, 
[src]

Adds a method to the existing list of allowed request methods.

Panics

Panics if the provided argument is not a valid http::Method.

pub fn allow_methods<I>(mut self: Self, methods: I) -> Self where
    I: IntoIterator,
    Method: TryFrom<I::Item>, 
[src]

Adds multiple methods to the existing list of allowed request methods.

Panics

Panics if the provided argument is not a valid http::Method.

pub fn allow_header<H>(mut self: Self, header: H) -> Self where
    HeaderName: TryFrom<H>, 
[src]

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.

pub fn allow_headers<I>(mut self: Self, headers: I) -> Self where
    I: IntoIterator,
    HeaderName: TryFrom<I::Item>, 
[src]

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.

pub fn expose_header<H>(mut self: Self, header: H) -> Self where
    HeaderName: TryFrom<H>, 
[src]

Adds a header to the list of exposed headers.

Panics

Panics if the provided argument is not a valid http::header::HeaderName.

pub fn expose_headers<I>(mut self: Self, headers: I) -> Self where
    I: IntoIterator,
    HeaderName: TryFrom<I::Item>, 
[src]

Adds multiple headers to the list of exposed headers.

Panics

Panics if any of the headers are not a valid http::header::HeaderName.

pub fn allow_any_origin(mut self: Self) -> Self[src]

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.

pub fn allow_origin(self, origin: impl IntoOrigin) -> Self[src]

Add an origin to the existing list of allowed Origins.

Panics

Panics if the provided argument is not a valid Origin.

pub fn allow_origins<I>(mut self: Self, origins: I) -> Self where
    I: IntoIterator,
    I::Item: IntoOrigin
[src]

Add multiple origins to the existing list of allowed Origins.

Panics

Panics if the provided argument is not a valid Origin.

pub fn max_age(mut self: Self, seconds: impl Seconds) -> Self[src]

Sets the Access-Control-Max-Age header.

Example

use std::time::Duration;
use salvo_core::prelude::*;;

let cors = salvo_extra::cors::cors()
    .max_age(30) // 30u32 seconds
    .max_age(Duration::from_secs(30)); // or a Duration

pub fn build(self) -> CorsHandler[src]

Builds the Cors wrapper from the configured settings.

This step isn't required, as the Builder itself can be passed to Filter::with. This just allows constructing once, thus not needing to pay the cost of "building" every time.

Trait Implementations

impl Clone for Builder[src]

impl Debug for Builder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]