Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scientific-dev/custom-socket
A custom socket for deno to add custom headers!
https://github.com/scientific-dev/custom-socket
custom deno headers
Last synced: 3 months ago
JSON representation
A custom socket for deno to add custom headers!
- Host: GitHub
- URL: https://github.com/scientific-dev/custom-socket
- Owner: scientific-dev
- License: mit
- Created: 2021-03-25T14:47:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-16T10:40:39.000Z (over 3 years ago)
- Last Synced: 2024-11-16T13:46:47.498Z (3 months ago)
- Topics: custom, deno, headers
- Language: TypeScript
- Homepage: https://deno.land/x/custom_socket
- Size: 16.6 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Custom Socket
As of current deno version, deno does not supports adding custom headers to the socket beacause deno follows the js web standards. So for people who want custom headers. Here is a module for it.
This module helps you to add custom headers something like this> This package is made for some development issues. If you find bugs report an issue or create an pull request.
```ts
import WS from "https://raw.githubusercontent.com/scientific-dev/custom-socket/main/mod.ts";const headers = {
Authorization: "Bearer token"
};const ws = new WS("wss://somedomain.com", headers);
ws.onopen = (ev: Event) => console.log('Socket has been opened');
ws.onmessage = (ev: MessageEvent) => console.log(ev.data);
ws.onclose = (ev: CloseEvent) => console.log('Socket has been closed');
ws.onerror = (ev: ErrorEvent) => console.log(ev.errior);
```This package uses the codes of https://deno.land/[email protected]/ws and uses the latest updated standard libraries and a better `WebSocket` implementation for it.