httpd: Add `CorsLayer` to `/raw` endpoint
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
parent
c427f41379
commit
00ea587c6d
|
|
@ -1,11 +1,13 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum::http::{header, StatusCode};
|
use axum::http::{header, Method, StatusCode};
|
||||||
use axum::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
use axum::routing::get;
|
use axum::routing::get;
|
||||||
use axum::Router;
|
use axum::Router;
|
||||||
use hyper::HeaderMap;
|
use hyper::HeaderMap;
|
||||||
|
use tower_http::cors;
|
||||||
|
|
||||||
use radicle::prelude::Id;
|
use radicle::prelude::Id;
|
||||||
use radicle::profile::Profile;
|
use radicle::profile::Profile;
|
||||||
|
|
@ -93,6 +95,13 @@ pub fn router(profile: Arc<Profile>) -> Router {
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/:project/:sha/*path", get(file_handler))
|
.route("/:project/:sha/*path", get(file_handler))
|
||||||
.with_state(profile)
|
.with_state(profile)
|
||||||
|
.layer(
|
||||||
|
cors::CorsLayer::new()
|
||||||
|
.max_age(Duration::from_secs(86400))
|
||||||
|
.allow_origin(cors::Any)
|
||||||
|
.allow_methods([Method::GET])
|
||||||
|
.allow_headers([header::CONTENT_TYPE]),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn file_handler(
|
async fn file_handler(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue