blob: 23f20c44f721a3d09df958e1bd080f675014794e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
pub mod get;
pub mod post;
pub use get::get_handler;
pub use post::normalize_mf2;
pub use post::post_handler;
pub struct CORSMiddleware {}
use crate::database;
use crate::ApplicationState;
use async_trait::async_trait;
use tide::{Next, Request, Result};
#[async_trait]
impl<B> tide::Middleware<ApplicationState<B>> for CORSMiddleware
where
B: database::Storage + Send + Sync + Clone,
{
async fn handle(
&self,
req: Request<ApplicationState<B>>,
next: Next<'_, ApplicationState<B>>,
) -> Result {
let mut res = next.run(req).await;
res.insert_header("Access-Control-Allow-Origin", "*");
Ok(res)
}
}
|