wsx

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 3 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)
    }
}))

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 struct {
	ReadBufferSize    int
	WriteBufferSize   int
	Subprotocols      []string
	EnableCompression bool
	// CheckOrigin defaults to allow-all (zip is multi-tenant; gate via
	// CORS or auth middleware at the route level instead).
	CheckOrigin func(ctx *fasthttp.RequestCtx) bool
}

Config configures the WebSocket upgrade.

type Conn

type Conn = websocket.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