From aec5a646c9218a0a0da62cbcd1f28bc23c242540 Mon Sep 17 00:00:00 2001 From: Andy Hayden Date: Sun, 27 Oct 2019 06:04:42 -0700 Subject: feat: top-level-for-await (#3212) --- tools/deno_http_proxy.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tools') 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 { - console.log(`Proxy listening on http://${addr}/`); - for await (const req of server) { - proxyRequest(req); - } -} - async function proxyRequest(req: ServerRequest): Promise { const url = `http://${originAddr}${req.url}`; const resp = await fetch(url, { @@ -21,4 +14,7 @@ async function proxyRequest(req: ServerRequest): Promise { req.respond(resp); } -main(); +console.log(`Proxy listening on http://${addr}/`); +for await (const req of server) { + proxyRequest(req); +} -- cgit v1.2.3