mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
5beec3f106
- Merge "Deno.serve()" and "Deno.serveTls()" API - Remove first argument and use "fetch" field options instead - Update type declarations - Add more documentation
14 lines
297 B
JavaScript
14 lines
297 B
JavaScript
const { serve, upgradeHttp } = Deno;
|
|
const u8 = Deno.core.encode("HTTP/1.1 101 Switching Protocols\r\n\r\n");
|
|
|
|
async function fetch(req) {
|
|
const [conn, _firstPacket] = upgradeHttp(req);
|
|
await conn.write(u8);
|
|
await conn.close();
|
|
}
|
|
|
|
serve({
|
|
fetch,
|
|
hostname: "127.0.0.1",
|
|
port: 9000,
|
|
});
|