summaryrefslogtreecommitdiff
path: root/cli/bench
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-08-19 14:36:01 +0200
committerGitHub <noreply@github.com>2022-08-19 14:36:01 +0200
commit5beec3f106b0890cc76150d0e3b3661c576d4c3b (patch)
tree9692e24bdb5a7e1d1c883b91961cdacff3e6708c /cli/bench
parent1848c7e361f1a3a33487b60ab6fcb61ed1f62273 (diff)
feat(unstable): change Deno.serve() API (#15498)
- Merge "Deno.serve()" and "Deno.serveTls()" API - Remove first argument and use "fetch" field options instead - Update type declarations - Add more documentation
Diffstat (limited to 'cli/bench')
-rw-r--r--cli/bench/http/deno_flash_hono_router.js2
-rw-r--r--cli/bench/http/deno_flash_send_file.js4
-rw-r--r--cli/bench/http/deno_http_flash.js5
-rw-r--r--cli/bench/http/deno_reactdom_ssr_flash.jsx9
-rw-r--r--cli/bench/testdata/deno_upgrade_http.js5
5 files changed, 15 insertions, 10 deletions
diff --git a/cli/bench/http/deno_flash_hono_router.js b/cli/bench/http/deno_flash_hono_router.js
index af6adc9ba..4c3336c63 100644
--- a/cli/bench/http/deno_flash_hono_router.js
+++ b/cli/bench/http/deno_flash_hono_router.js
@@ -7,4 +7,4 @@ const [hostname, port] = addr.split(":");
const app = new Hono();
app.get("/", (c) => c.text("Hello, World!"));
-Deno.serve(app.fetch, { port: Number(port), hostname });
+Deno.serve({ fetch: app.fetch, port: Number(port), hostname });
diff --git a/cli/bench/http/deno_flash_send_file.js b/cli/bench/http/deno_flash_send_file.js
index db2ad7a82..81e8c4991 100644
--- a/cli/bench/http/deno_flash_send_file.js
+++ b/cli/bench/http/deno_flash_send_file.js
@@ -6,9 +6,9 @@ const { serve } = Deno;
const path = new URL("../testdata/128k.bin", import.meta.url).pathname;
-function handler() {
+function fetch() {
const file = Deno.openSync(path);
return new Response(file.readable);
}
-serve(handler, { hostname, port: Number(port) });
+serve({ fetch, hostname, port: Number(port) });
diff --git a/cli/bench/http/deno_http_flash.js b/cli/bench/http/deno_http_flash.js
index 5d3de68f4..3823bb9cd 100644
--- a/cli/bench/http/deno_http_flash.js
+++ b/cli/bench/http/deno_http_flash.js
@@ -4,11 +4,12 @@ const addr = Deno.args[0] || "127.0.0.1:4500";
const [hostname, port] = addr.split(":");
const { serve } = Deno;
-function handler() {
+function fetch() {
return new Response("Hello World");
}
-serve(handler, {
+serve({
+ fetch,
hostname,
port,
});
diff --git a/cli/bench/http/deno_reactdom_ssr_flash.jsx b/cli/bench/http/deno_reactdom_ssr_flash.jsx
index 571545b27..0d749c634 100644
--- a/cli/bench/http/deno_reactdom_ssr_flash.jsx
+++ b/cli/bench/http/deno_reactdom_ssr_flash.jsx
@@ -19,8 +19,11 @@ const headers = {
};
serve(
- async () => {
- return new Response(await renderToReadableStream(<App />), headers);
+ {
+ fetch: async () => {
+ return new Response(await renderToReadableStream(<App />), headers);
+ },
+ hostname,
+ port,
},
- { hostname, port },
);
diff --git a/cli/bench/testdata/deno_upgrade_http.js b/cli/bench/testdata/deno_upgrade_http.js
index 638761cf6..e3252ffd1 100644
--- a/cli/bench/testdata/deno_upgrade_http.js
+++ b/cli/bench/testdata/deno_upgrade_http.js
@@ -1,13 +1,14 @@
const { serve, upgradeHttp } = Deno;
const u8 = Deno.core.encode("HTTP/1.1 101 Switching Protocols\r\n\r\n");
-async function handler(req) {
+async function fetch(req) {
const [conn, _firstPacket] = upgradeHttp(req);
await conn.write(u8);
await conn.close();
}
-serve(handler, {
+serve({
+ fetch,
hostname: "127.0.0.1",
port: 9000,
});