websocket

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Overview

Package websocket provides the Websocket transport.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPacketEndpoint

func NewPacketEndpoint(urlStr string, se transport.StreamEndpoint, opts ...Option) (func(context.Context) (net.Conn, error), error)

NewPacketEndpoint creates a new Websocket Packet Endpoint. Each packet is exchanged as a Websocket message.

func NewStreamEndpoint

func NewStreamEndpoint(urlStr string, se transport.StreamEndpoint, opts ...Option) (func(context.Context) (transport.StreamConn, error), error)

NewStreamEndpoint creates a new Websocket Stream Endpoint. Streams are sent over Websockets, with each Write becoming a separate message. Half-close is supported: CloseRead will not close the Websocket connection, while CloseWrite sends a Websocket close but continues reading until a close is received from the server.

func Upgrade

func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (transport.StreamConn, error)

Upgrade upgrades an HTTP connection to a WebSocket connection. It returns a transport.StreamConn representing the WebSocket connection, or an error if the upgrade fails.

Types

type Option

type Option func(c *options)

Option for building the Websocket endpoint.

func WithHTTPHeaders

func WithHTTPHeaders(headers http.Header) Option

WithHTTPHeaders specifies the HTTP headers to use.

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) Option

WithTLSConfig specifies the TLS configuration to use. TODO(fortuna): Use Outline TLS instead.

Jump to

Keyboard shortcuts

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