[−][src]Struct roa::cors::Cors
A middleware to deal with Cross-Origin Resource Sharing (CORS).
Default
The default Cors middleware works well, it will use "origin" as value of response header "access-control-allow-origin",
And in preflight request, it will use "access-control-request-method" as value of "access-control-allow-methods" and use "access-control-request-headers" as value of "access-control-allow-headers".
Build a default Cors middleware:
use roa::cors::Cors; let default_cors = Cors::new();
Config
You can also configure it:
use roa::cors::Cors; use roa::http::header::{CONTENT_DISPOSITION, AUTHORIZATION, WWW_AUTHENTICATE}; use roa::http::Method; let configured_cors = Cors::builder() .allow_credentials(true) .max_age(86400) .allow_origin("https://github.com") .allow_methods(vec![Method::GET, Method::POST]) .allow_method(Method::PUT) .expose_headers(vec![CONTENT_DISPOSITION]) .expose_header(WWW_AUTHENTICATE) .allow_headers(vec![AUTHORIZATION]) .allow_header(CONTENT_DISPOSITION) .build();
Methods
impl Cors
[src]
Trait Implementations
impl Debug for Cors
[src]
impl Default for Cors
[src]
impl<S: State> Middleware<S> for Cors
[src]
fn handle<'async_trait>(
self: Arc<Self>,
ctx: Context<S>,
next: Next
) -> Pin<Box<dyn Future<Output = Result> + 'async_trait>> where
Self: 'async_trait,
[src]
self: Arc<Self>,
ctx: Context<S>,
next: Next
) -> Pin<Box<dyn Future<Output = Result> + 'async_trait>> where
Self: 'async_trait,
fn end<'async_trait>(
self: Arc<Self>,
ctx: Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
Self: 'async_trait,
[src]
self: Arc<Self>,
ctx: Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
Self: 'async_trait,
Auto Trait Implementations
impl RefUnwindSafe for Cors
impl Send for Cors
impl Sync for Cors
impl Unpin for Cors
impl UnwindSafe for Cors
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<S, F, T> Middleware<S> for T where
F: 'static + Future<Output = Result<(), Error>>,
S: State,
T: 'static + Sync + Send + Fn(Context<S>, Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>) -> F,
[src]
F: 'static + Future<Output = Result<(), Error>>,
S: State,
T: 'static + Sync + Send + Fn(Context<S>, Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>) -> F,
fn handle<'async_trait>(
self: Arc<T>,
ctx: Context<S>,
next: Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
T: 'async_trait,
[src]
self: Arc<T>,
ctx: Context<S>,
next: Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
T: 'async_trait,
fn end<'async_trait>(
self: Arc<Self>,
ctx: Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
Self: 'async_trait,
[src]
self: Arc<Self>,
ctx: Context<S>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
Self: 'async_trait,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,