Documentation
¶
Overview ¶
Package ws is the one WebSocket upgrade zip performs. wsx.Upgrade (an untyped route) and a typed op answering zip.Socket both reach it.
Index ¶
Constants ¶
View Source
const Refusal = "this address speaks WebSocket: connect with an Upgrade: websocket request"
Refusal is the sentence a plain request to a WebSocket address is answered with, beside 426 and Upgrade: websocket (RFC 9110 §15.5.22).
View Source
const Version = "13"
Version is the protocol version a handshake must ask for (RFC 6455).
Variables ¶
This section is empty.
Functions ¶
func Admits ¶
func Admits(rc *fasthttp.RequestCtx, origins []string) bool
Admits reports whether a request's Origin may open a connection: a request with no Origin (not a browser), one whose Origin names the request's own host, and one whose Origin is among origins, "*" being any.
func Is ¶
func Is(rc *fasthttp.RequestCtx) bool
Is reports whether the request asks to become a WebSocket.
Types ¶
type Config ¶
type Config struct {
// ReadBufferSize and WriteBufferSize size the connection's I/O buffers in
// bytes; zero takes the library's default.
ReadBufferSize int
WriteBufferSize int
// Subprotocols are the protocols the server speaks, in its order of
// preference; the first one the client also offers is selected.
Subprotocols []string
// EnableCompression negotiates per-message deflate when the client offers it.
EnableCompression bool
// CheckOrigin decides whether a request's Origin may open a connection.
// Nil is the library's: an Origin, when there is one, must name the
// request's own host.
CheckOrigin func(ctx *fasthttp.RequestCtx) bool
}
Config configures an upgrade.
Click to show internal directories.
Click to hide internal directories.