pub trait CorsRoute<C, P> where
    C: PipelineHandleChain<P> + Copy + Send + Sync + 'static,
    P: RefUnwindSafe + Send + Sync + 'static, 
{ 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

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

Implementors