mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 02:47:45 +08:00
refactor(gateway): 将 CF 头剥离中间件下移至各 router 构建函数并重构为前缀匹配
This commit is contained in:
@@ -43,19 +43,19 @@ pub fn build_router_with_state(state: AppState) -> Router {
|
||||
middleware::frontdoor_cors_middleware,
|
||||
));
|
||||
}
|
||||
router
|
||||
middleware::apply_cf_header_stripping(router)
|
||||
}
|
||||
|
||||
pub fn attach_static_frontend(router: Router, static_dir: impl Into<PathBuf>) -> Router {
|
||||
let static_dir = static_dir.into();
|
||||
let index_html = static_dir.join("index.html");
|
||||
router.layer(axum::middleware::from_fn_with_state(
|
||||
middleware::apply_cf_header_stripping(router.layer(axum::middleware::from_fn_with_state(
|
||||
FrontendStaticState {
|
||||
static_dir,
|
||||
index_html,
|
||||
},
|
||||
frontend_static_middleware,
|
||||
))
|
||||
)))
|
||||
}
|
||||
|
||||
async fn frontend_static_middleware(
|
||||
|
||||
Reference in New Issue
Block a user