A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: f38b9322e8fdcf7c9c05e892e86e45bd3b4300b0 (665 bytes)[doc][blame][raw]
1
pub struct CorsMiddleware {2
origin: String,3
}5
impl CorsMiddleware {6
pub fn new(origin: &str) -> Self {7
Self {8
origin: origin.into(),9
}10
}11
}13
#[tide::utils::async_trait]14
impl<State: Clone + Send + Sync + 'static> tide::Middleware<State> for CorsMiddleware {15
async fn handle(&self, req: tide::Request<State>, next: tide::Next<'_, State>) -> tide::Result {16
let mut res = next.run(req).await;17
res.insert_header("Access-Control-Allow-Origin", &self.origin);18
res.insert_header("Access-Control-Allow-Headers", "*");19
res.insert_header("Access-Control-Allow-Methods", "*");20
Ok(res)21
}22
}