From a1f5ee3935a9493cf30dc2cf6135c289dd70c9f6 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 24 Apr 2021 21:35:18 +0800 Subject: [PATCH] feat: add http2.dart --- http2.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 http2.dart diff --git a/http2.dart b/http2.dart new file mode 100644 index 0000000..f1cc474 --- /dev/null +++ b/http2.dart @@ -0,0 +1,17 @@ +const listener = Deno.listenTls({ + port: 443, + certFile: "./cert.pem", + keyFile: "./key.pem", + alpnProtocols: ["h2", "http/1.1"], +}); + +for await (const conn of listener) { + handleConn(conn); +} + +async function handleConn(conn: Deno.Conn) { + const httpConn = Deno.serveHttp(conn); + for await (const { request, respondWith } of httpConn) { + respondWith(new Response(`Responding to ${request.url}`)); + } +}