[][src]Struct rocket_cors::Cors

pub struct Cors { /* fields omitted */ }

Response generator and Fairing for CORS

This struct can be as Fairing or in an ad-hoc manner to generate CORS response. See the documentation at the crate root for usage information.

This struct can be created by using CorsOptions::to_cors or Cors::from_options.

Methods

impl Cors[src]

pub fn from_options(options: &CorsOptions) -> Result<Self, Error>[src]

Create a Cors struct from a CorsOptions

pub fn respond_owned<'r, F, R>(
    self,
    handler: F
) -> Result<ManualResponder<'r, F, R>, Error> where
    F: FnOnce(Guard<'r>) -> R + 'r,
    R: Responder<'r>, 
[src]

Manually respond to a request with CORS checks and headers using an Owned Cors.

Use this variant when your Cors struct will not live at least as long as the whole 'r lifetime of the request.

After the CORS checks are done, the passed in handler closure will be run to generate a final response. You will have to merge your response with the Guard that you have been passed in to include the CORS headers.

See the documentation at the crate root for usage information.

pub fn respond_borrowed<'r, F, R>(
    &'r self,
    handler: F
) -> Result<ManualResponder<'r, F, R>, Error> where
    F: FnOnce(Guard<'r>) -> R + 'r,
    R: Responder<'r>, 
[src]

Manually respond to a request with CORS checks and headers using a borrowed Cors.

Use this variant when your Cors struct will live at least as long as the whole 'r lifetime of the request. If you are getting your Cors from Rocket's state, you will have to use the inner function to get a longer borrowed lifetime.

After the CORS checks are done, the passed in handler closure will be run to generate a final response. You will have to merge your response with the Guard that you have been passed in to include the CORS headers.

See the documentation at the crate root for usage information.

Trait Implementations

impl Clone for Cors[src]

impl Debug for Cors[src]

impl Fairing for Cors[src]

Auto Trait Implementations

impl Send for Cors

impl Sync for Cors

impl Unpin for Cors

impl UnwindSafe for Cors

impl !RefUnwindSafe for Cors

Blanket Implementations

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

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

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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<T> Typeable for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input,