Skip to main content

proxy_handler

Function proxy_handler 

Source
pub async fn proxy_handler(
    __arg0: State<AppState>,
    __arg1: Path<(String, String)>,
    req: Request,
) -> Response
Expand description

ANY /api/{service}/{*path} — reverse-proxy to the service’s live URL.

Why: Lets operators and the console SPA reach every daemon API through the console port without knowing per-daemon port numbers. What: Resolves the service’s base URL from the background health-poll cache, normalises the URL (double-scheme guard), forwards the request (method, safe headers, body) via reqwest, and streams the upstream response back. Unknown service keys → 400; daemon not reachable → 502. Test: URL construction is unit-tested in tests below. End-to-end proxy behaviour requires a live daemon and is not tested in CI.