Registry / networking / gorilla-websocket

gorilla-websocket

JSON →
library1.5.3gogounverified

Package websocket implements the WebSocket protocol defined in RFC 6455.

go get github.com/gorilla/websocket
INSTALL
IMPORT
SIG · GORILLA-WEBSOCKET
G
gorilla-websocket
networkinggov1.5.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

websocket
✓ github.com/gorilla/websocket

Upgrade an HTTP connection to WebSocket and echo received messages.

import "github.com/gorilla/websocket" var upgrader = websocket.Upgrader{} func handler(w http.ResponseWriter, r *http.Request) { conn, _ := upgrader.Upgrade(w, r, nil) defer conn.Close() for { _, msg, _ := conn.ReadMessage() conn.WriteMessage(websocket.TextMessage, msg) } }
Debug
Known issues
gotchaThe default CheckOrigin allows all origins, which may be insecure in production.
fix
Set Upgrader.CheckOrigin to a function that validates the Origin header.
affects: all
Upgrade
Version history
1.5.3latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
gorilla-websocket — go get gorilla-websocket · libregistry