wsx

package
v1.37.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package wsx provides Fiber-v3-compatible WebSocket support via fasthttp/websocket. The public surface is intentionally small:

app.Get("/ws", wsx.Upgrade(func(c *wsx.Conn) error {
    for {
        _, msg, err := c.ReadMessage()
        if err != nil { return err }
        _ = c.WriteMessage(wsx.TextMessage, msg)
    }
}))

A typed op that answers a WebSocket returns a zip.Socket instead; both run the same upgrade (internal/ws).

Index

Constants

View Source
const (
	TextMessage   = websocket.TextMessage
	BinaryMessage = websocket.BinaryMessage
	CloseMessage  = websocket.CloseMessage
	PingMessage   = websocket.PingMessage
	PongMessage   = websocket.PongMessage
)

Message-type constants re-exported for convenience.

Variables

This section is empty.

Functions

func Upgrade

func Upgrade(fn Handler, opts ...Config) zip.Handler

Upgrade returns a zip.Handler that upgrades the HTTP connection to a WebSocket and calls fn with the established *Conn.

Types

type Config

type Config = ws.Config

Config configures the WebSocket upgrade. It is the type zip.Socket's Config field holds.

type Conn

type Conn = ws.Conn

Conn is the WebSocket connection passed to wsx handlers.

type Handler

type Handler func(c *Conn) error

Handler is the wsx handler signature.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL