ws<T> method

void ws<T>(
  1. String path,
  2. Hooks hooks, [
  3. Handler<T>? fallback
])

Register a websocket handler with hooks.

Implementation

void ws<T>(String path, Hooks hooks, [Handler<T>? fallback]) {
  return get(path, (event) async {
    if (await upgrade(event, hooks)) {
      return Response(null, status: 101);
    }

    return fallback?.call(event) ?? Response(null, status: 426);
  });
}