diff options
Diffstat (limited to 'tools/deno_http_proxy.ts')
-rw-r--r-- | tools/deno_http_proxy.ts | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/tools/deno_http_proxy.ts b/tools/deno_http_proxy.ts index 728e4fd3f..5f601723a 100644 --- a/tools/deno_http_proxy.ts +++ b/tools/deno_http_proxy.ts @@ -5,13 +5,6 @@ const addr = Deno.args[1] || "127.0.0.1:4500"; const originAddr = Deno.args[2] || "127.0.0.1:4501"; const server = serve(addr); -async function main(): Promise<void> { - console.log(`Proxy listening on http://${addr}/`); - for await (const req of server) { - proxyRequest(req); - } -} - async function proxyRequest(req: ServerRequest): Promise<void> { const url = `http://${originAddr}${req.url}`; const resp = await fetch(url, { @@ -21,4 +14,7 @@ async function proxyRequest(req: ServerRequest): Promise<void> { req.respond(resp); } -main(); +console.log(`Proxy listening on http://${addr}/`); +for await (const req of server) { + proxyRequest(req); +} |