mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat: top-level-for-await (#3212)
This commit is contained in:
parent
51dd91a3cc
commit
aec5a646c9
18 changed files with 257 additions and 263 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue