From db7b189d700f8c8616a1258076912face1308b8d Mon Sep 17 00:00:00 2001 From: Marcos Candeia Date: Fri, 13 Sep 2024 12:08:39 -0300 Subject: [PATCH] Add connected hosts path Signed-off-by: Marcos Candeia --- server.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server.ts b/server.ts index 68bd542..0f1456b 100644 --- a/server.ts +++ b/server.ts @@ -63,6 +63,7 @@ export const serve = (options: ServeOptions): Deno.HttpServer => { }); }; +const CONNECTED_HOSTS_PATH = "/_hosts"; /** * Creates a handler function for serving requests, with support for WebSocket connections * and forwarding requests to registered domains. @@ -80,6 +81,13 @@ export const serveHandler = ( return async (req) => { const url = new URL(req.url); + if (url.pathname === CONNECTED_HOSTS_PATH) { + return new Response(JSON.stringify(hostToClientId), { + headers: { + "content-type": "application/json", + }, + }); + } if (url.pathname === connectPath) { const { socket, response } = Deno.upgradeWebSocket(req); const clientVersion = url.searchParams.get(CLIENT_VERSION_QUERY_STRING);