https://github.com/httpland/http-websocket
HTTP request for websocket with standard Request and Response
https://github.com/httpland/http-websocket
deno handler http request response rfc-6455 validate websocket
Last synced: 24 days ago
JSON representation
HTTP request for websocket with standard Request and Response
- Host: GitHub
- URL: https://github.com/httpland/http-websocket
- Owner: httpland
- License: mit
- Created: 2022-08-04T02:09:07.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-19T03:24:55.000Z (almost 4 years ago)
- Last Synced: 2026-03-29T01:26:01.231Z (3 months ago)
- Topics: deno, handler, http, request, response, rfc-6455, validate, websocket
- Language: TypeScript
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# websocket-handler
WebSocket handler implementation and other utilities for working with status
codes.
## What
This is the WebSocket **handler** framework. It handles HTTP Request validation
and error handling, which you must do when you create a WebSocket Server.
You can concentrate only on WebSocket behavior.
## Features
- Validation for HTTP request what upgrade to WebSocket.
- Tiny, minimum interface.
## Quick View
```ts
import {
createHandler,
SocketHandler,
} from "https://deno.land/x/ws_handler@$VERSION/mod.ts";
import { serve } from "https://deno.land/std@$VERSION/http/mod.ts";
const socketHandler: SocketHandler = (socket) => {
socket.onopen = () => {
socket.send("hello");
};
};
const handler = createHandler(socketHandler);
serve(handler);
```
## API
### createHandler
Create WebSocket request handler.
#### Example
```ts
import {
createHandler,
SocketHandler,
} from "https://deno.land/x/ws_handler@$VERSION/mod.ts";
const socketHandler: SocketHandler = (socket) => {
socket.onopen = () => {
socket.send("hello");
};
};
const handler = createHandler(socketHandler);
```
## License
Copyright © 2022-present [TomokiMiyauci](https://github.com/TomokiMiyauci).
Released under the [MIT](./LICENSE) license