pub trait CorsRoute<C, P>where
    C: PipelineHandleChain<P> + Copy + Send + Sync + 'static,
    P: RefUnwindSafe + Send + Sync + 'static,{
    // Required method
    fn cors(&mut self, path: &str, method: Method);
}
Expand description

Add CORS routing for your path. This is required for handling preflight requests.

Example:

build_simple_router(|router| {
	// The handler that needs preflight handling
	router.post("/foo").to(|state| {
		let mut res: Response<Body> = unimplemented!();
		handle_cors(&state, &mut res);
		(state, res)
	});
	// Add preflight handling
	router.cors("/foo", Method::POST);
});

Required Methods§

source

fn cors(&mut self, path: &str, method: Method)

Handle a preflight request on path for method. To configure the behaviour, use CorsConfig.

Implementors§

source§

impl<D, C, P> CorsRoute<C, P> for Dwhere D: DrawRoutes<C, P>, C: PipelineHandleChain<P> + Copy + Send + Sync + 'static, P: RefUnwindSafe + Send + Sync + 'static,