refactor(gateway): 将 CF 头剥离中间件下移至各 router 构建函数并重构为前缀匹配

This commit is contained in:
fawney19
2026-04-22 21:10:16 +08:00
parent cf6228f525
commit c8d7dbd8d6
6 changed files with 166 additions and 56 deletions

View File

@@ -20,6 +20,7 @@ use thiserror::Error;
use crate::execution_runtime::{
build_direct_execution_frame_stream, DirectSyncExecutionRuntime, ExecutionRuntimeTransportError,
};
use crate::middleware;
const EXECUTION_RUNTIME_COMPONENT: &str = "aether-gateway-execution-runtime";
const REQUEST_GATE_NAME: &str = "execution_runtime_requests";
@@ -128,12 +129,14 @@ pub fn build_execution_runtime_router_with_request_gates(
.with_distributed_request_gate(gate),
None => ExecutionRuntimeAppState::with_request_concurrency_limit(limit),
};
Router::new()
.route("/health", get(health))
.route("/metrics", get(metrics))
.route("/v1/execute/sync", post(execute_sync))
.route("/v1/execute/stream", post(execute_stream))
.with_state(state)
middleware::apply_cf_header_stripping(
Router::new()
.route("/health", get(health))
.route("/metrics", get(metrics))
.route("/v1/execute/sync", post(execute_sync))
.route("/v1/execute/stream", post(execute_stream))
.with_state(state),
)
}
pub async fn serve_execution_runtime_tcp(