2026-03-31 19:19:04 +08:00
|
|
|
use super::{classified, ClassifiedRoute};
|
2026-04-07 02:50:19 +08:00
|
|
|
use crate::tunnel::{is_tunnel_heartbeat_path, is_tunnel_node_status_path, TUNNEL_ROUTE_FAMILY};
|
2026-03-31 19:19:04 +08:00
|
|
|
|
|
|
|
|
pub(super) fn classify_internal_route(
|
|
|
|
|
method: &http::Method,
|
|
|
|
|
normalized_path: &str,
|
|
|
|
|
) -> Option<ClassifiedRoute> {
|
2026-09-04 03:45:52 +08:00
|
|
|
if normalized_path == "/api/internal/gateway"
|
|
|
|
|
|| normalized_path.starts_with("/api/internal/gateway/")
|
|
|
|
|
{
|
|
|
|
|
let route_kind = match (method, normalized_path) {
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/resolve") => "resolve",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/auth-context") => "auth_context",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/decision-sync") => "decision_sync",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/decision-stream") => "decision_stream",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/plan-sync") => "plan_sync",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/plan-stream") => "plan_stream",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/report-sync") => "report_sync",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/report-stream") => "report_stream",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/finalize-sync") => "finalize_sync",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/execute-sync") => "execute_sync",
|
|
|
|
|
(&http::Method::POST, "/api/internal/gateway/execute-stream") => "execute_stream",
|
2026-04-04 01:40:24 +08:00
|
|
|
_ => "unhandled",
|
2026-03-31 19:19:04 +08:00
|
|
|
};
|
|
|
|
|
Some(classified(
|
|
|
|
|
"internal_proxy",
|
2026-04-04 01:40:24 +08:00
|
|
|
"internal_gateway",
|
2026-03-31 19:19:04 +08:00
|
|
|
route_kind,
|
|
|
|
|
"",
|
|
|
|
|
false,
|
|
|
|
|
))
|
2026-04-03 14:59:58 +08:00
|
|
|
} else if method == http::Method::POST && is_tunnel_heartbeat_path(normalized_path) {
|
2026-03-31 19:19:04 +08:00
|
|
|
Some(classified(
|
|
|
|
|
"internal_proxy",
|
2026-04-03 14:59:58 +08:00
|
|
|
TUNNEL_ROUTE_FAMILY,
|
2026-03-31 19:19:04 +08:00
|
|
|
"heartbeat",
|
|
|
|
|
"",
|
|
|
|
|
false,
|
|
|
|
|
))
|
2026-04-03 14:59:58 +08:00
|
|
|
} else if method == http::Method::POST && is_tunnel_node_status_path(normalized_path) {
|
2026-03-31 19:19:04 +08:00
|
|
|
Some(classified(
|
|
|
|
|
"internal_proxy",
|
2026-04-03 14:59:58 +08:00
|
|
|
TUNNEL_ROUTE_FAMILY,
|
2026-03-31 19:19:04 +08:00
|
|
|
"node_status",
|
|
|
|
|
"",
|
|
|
|
|
false,
|
|
|
|
|
))
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
}
|