Handle WebSocket

Servest provides WebSocket handler for Router API.router.ws() is register for WebSocket route.
Handler will be called after WebSocket upgrade finished.

import { createApp } from "https://servestjs.org/@v1.1.0/mod.ts";
import type { WebSocket } from "https://deno.land/std/ws/mod.ts";

function handleHandshake(sock: WebSocket) {
  async function handleMessage(sock: WebSocket) {
    for await (const msg of sock) {
      if (typeof msg === "string") {
        sock.send(msg);
      }
    }
  }
  handleMessage(sock);
}
const app = createApp();
app.ws("/ws", handleHandshake);
app.listen({ port: 8899 });