From 4ef08a58dfbcf893f25fd59917aa946f455e85f2 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 24 Aug 2022 00:08:56 +0200 Subject: feat: update `Deno.serve` function signature (#15563) This commit changes the `Deno.serve` function signature to be more versatile and easier to use. It is now a drop in replacement for std/http's `serve`. The input validation has also been reworked. --- cli/bench/testdata/deno_upgrade_http.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'cli/bench/testdata') diff --git a/cli/bench/testdata/deno_upgrade_http.js b/cli/bench/testdata/deno_upgrade_http.js index e3252ffd1..7274459c9 100644 --- a/cli/bench/testdata/deno_upgrade_http.js +++ b/cli/bench/testdata/deno_upgrade_http.js @@ -1,14 +1,10 @@ const { serve, upgradeHttp } = Deno; const u8 = Deno.core.encode("HTTP/1.1 101 Switching Protocols\r\n\r\n"); -async function fetch(req) { +async function handler(req) { const [conn, _firstPacket] = upgradeHttp(req); await conn.write(u8); await conn.close(); } -serve({ - fetch, - hostname: "127.0.0.1", - port: 9000, -}); +serve(handler, { hostname: "127.0.0.1", port: 9000 }); -- cgit v1.2.3