ws

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialErrorResponse added in v0.5.0

func DialErrorResponse(err error) (*http.Response, bool)

DialErrorResponse returns the HTTP response from the WebSocket handshake error, if any.

func RequestFromContext

func RequestFromContext(ctx context.Context) *http.Request

RequestFromContext returns the accepted WebSocket request from the context.

Types

type ClientOptions

type ClientOptions struct {
	URL         string                // The URL of the WebSocket server
	DialContext context.Context       // Optional WebSocket dial context
	DialOptions websocket.DialOptions // Optional WebSocket dial options
	Handshake   HandshakeResponse     // Optionally run after successful WebSocket handshake
}

ClientOptions for Watch and Tunnel, implementing connect.Tunneler.

func (ClientOptions) Tunnel

func (o ClientOptions) Tunnel(ctx context.Context) (connect.Tunnel, error)

Tunnel implements connect.Tunneler and creates a connection over a WebSocket. On error a http.Response may be provided by DialErrorResponse.

func (ClientOptions) Watch

func (o ClientOptions) Watch(ctx context.Context, propose connect.ReceiveProposal) error

Watch implements connect.Watcher and watches for session proposals. On error a http.Response may be provided by DialErrorResponse.

type HandshakeResponse

type HandshakeResponse func(ctx context.Context, res *http.Response) (context.Context, error)

HandshakeResponse is called after receiving the WebSocket handshake response from the server.

type ServerOptions

type ServerOptions struct {
	AcceptOptions websocket.AcceptOptions // Optional WebSocket accept options
}

ServerOptions for TunnelHandler and EndpointHandler.

func (ServerOptions) EndpointHandler

func (o ServerOptions) EndpointHandler(ln connect.EndpointListener) http.Handler

EndpointHandler returns a new http.Handler for accepting WebSocket requests for watching endpoints.

func (ServerOptions) TunnelHandler

func (o ServerOptions) TunnelHandler(ln connect.TunnelListener) http.Handler

TunnelHandler returns a new http.Handler for accepting WebSocket requests for tunneling.

Jump to

Keyboard shortcuts

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