thruster/middleware/
cors.rs1use thruster_proc::middleware_fn;
2
3use crate::core::context::Context;
4use crate::core::{MiddlewareNext, MiddlewareResult};
5
6#[middleware_fn(_internal)]
10pub async fn cors<T: 'static + Context + Send>(
11 mut context: T,
12 next: MiddlewareNext<T>,
13) -> MiddlewareResult<T> {
14 context.set("Access-Control-Allow-Origin", "*");
15 context.set("Access-Control-Allow-Headers", "*");
16 context.set(
17 "Access-Control-Allow-Methods",
18 "GET, POST, PUT, DELETE, OPTIONS",
19 );
20
21 next(context).await
22}