Documentation
¶
Overview ¶
Package websocket provides the Websocket transport.
Index ¶
- func NewPacketEndpoint(urlStr string, se transport.StreamEndpoint, opts ...Option) (func(context.Context) (net.Conn, error), error)
- func NewStreamEndpoint(urlStr string, se transport.StreamEndpoint, opts ...Option) (func(context.Context) (transport.StreamConn, error), error)
- func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (transport.StreamConn, error)
- type Option
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 ¶
WithHTTPHeaders specifies the HTTP headers to use.
func WithTLSConfig ¶
WithTLSConfig specifies the TLS configuration to use. TODO(fortuna): Use Outline TLS instead.