Struct sfo_http::http_server::security::CorsMiddleware
source · pub struct CorsMiddleware { /* private fields */ }Expand description
Middleware for CORS
Example
use http_types::headers::HeaderValue;
use tide::security::{CorsMiddleware, Origin};
let cors = CorsMiddleware::new()
.allow_methods("GET, POST, OPTIONS".parse::<HeaderValue>().unwrap())
.allow_origin(Origin::from("*"))
.allow_credentials(false);Implementations§
source§impl CorsMiddleware
impl CorsMiddleware
sourcepub fn new() -> CorsMiddleware
pub fn new() -> CorsMiddleware
Creates a new Cors middleware.
sourcepub fn allow_credentials(self, allow_credentials: bool) -> CorsMiddleware
pub fn allow_credentials(self, allow_credentials: bool) -> CorsMiddleware
Set allow_credentials and return new Cors
sourcepub fn allow_headers<T>(self, headers: T) -> CorsMiddlewarewhere
T: Into<HeaderValue>,
pub fn allow_headers<T>(self, headers: T) -> CorsMiddlewarewhere T: Into<HeaderValue>,
Set allow_headers and return new Cors
sourcepub fn max_age<T>(self, max_age: T) -> CorsMiddlewarewhere
T: Into<HeaderValue>,
pub fn max_age<T>(self, max_age: T) -> CorsMiddlewarewhere T: Into<HeaderValue>,
Set max_age and return new Cors
sourcepub fn allow_methods<T>(self, methods: T) -> CorsMiddlewarewhere
T: Into<HeaderValue>,
pub fn allow_methods<T>(self, methods: T) -> CorsMiddlewarewhere T: Into<HeaderValue>,
Set allow_methods and return new Cors
sourcepub fn allow_origin<T>(self, origin: T) -> CorsMiddlewarewhere
T: Into<Origin>,
pub fn allow_origin<T>(self, origin: T) -> CorsMiddlewarewhere T: Into<Origin>,
Set allow_origin and return new Cors
sourcepub fn expose_headers<T>(self, headers: T) -> CorsMiddlewarewhere
T: Into<HeaderValue>,
pub fn expose_headers<T>(self, headers: T) -> CorsMiddlewarewhere T: Into<HeaderValue>,
Set expose_headers and return new Cors
Trait Implementations§
source§impl Clone for CorsMiddleware
impl Clone for CorsMiddleware
source§fn clone(&self) -> CorsMiddleware
fn clone(&self) -> CorsMiddleware
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for CorsMiddleware
impl Debug for CorsMiddleware
source§impl Default for CorsMiddleware
impl Default for CorsMiddleware
source§fn default() -> CorsMiddleware
fn default() -> CorsMiddleware
Returns the “default value” for a type. Read more
source§impl Hash for CorsMiddleware
impl Hash for CorsMiddleware
source§impl<State> Middleware<State> for CorsMiddlewarewhere
State: Clone + Send + Sync + 'static,
impl<State> Middleware<State> for CorsMiddlewarewhere State: Clone + Send + Sync + 'static,
source§fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
req: Request<State>,
next: Next<'life1, State>
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
CorsMiddleware: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>( &'life0 self, req: Request<State>, next: Next<'life1, State> ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, CorsMiddleware: 'async_trait,
Asynchronously handle the request, and return a response.
Auto Trait Implementations§
impl RefUnwindSafe for CorsMiddleware
impl Send for CorsMiddleware
impl Sync for CorsMiddleware
impl Unpin for CorsMiddleware
impl UnwindSafe for CorsMiddleware
Blanket Implementations§
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
Mutably borrows from an owned value. Read more