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.
Upgrades an HTTP connection to WebSocket and reads a message.
package main
import (
"log"
"net/http"
"github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
conn, _, _, err := ws.UpgradeHTTP(r, w)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
msg, op, err := wsutil.ReadClientData(conn)
if err != nil {
log.Fatal(err)
}
log.Printf("Received: %s (opcode %d)", msg, op)
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
1.4.0latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.