feat: add http2.dart

This commit is contained in:
2021-04-24 21:35:18 +08:00
parent 0ce5299044
commit a1f5ee3935

17
http2.dart Normal file
View File

@@ -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}`));
}
}