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/fasthttp/websocket
WebSocket echo server using fasthttp
package main
import (
"log"
"github.com/fasthttp/websocket"
"github.com/valyala/fasthttp"
)
var upgrader = websocket.FastHTTPUpgrader{}
func main() {
requestHandler := func(ctx *fasthttp.RequestCtx) {
err := upgrader.Upgrade(ctx, func(conn *websocket.Conn) {
for {
msgType, msg, err := conn.ReadMessage()
if err != nil {
return
}
if err := conn.WriteMessage(msgType, msg); err != nil {
return
}
}
})
if err != nil {
log.Print(err)
}
}
fasthttp.ListenAndServe(":8080", requestHandler)
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
1.5.12latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.