websocket

package
v0.2.2-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionCloseHandler

type ConnectionCloseHandler func(code int, text string) error

type DecodeIngressFunc

type DecodeIngressFunc func(context.Context, []byte) (request interface{}, err error)

Decode request on receiving.

type EncodeEgressFunc

type EncodeEgressFunc func(context.Context, interface{}) (response []byte, err error)

Encode response before sending.

type RequestFunc

type RequestFunc func(context.Context, *http.Request) context.Context

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	e WebSocketEndpoint,
	dec DecodeIngressFunc,
	enc EncodeEgressFunc,
	options ...ServerOption,
) *Server

func (Server) ServeHTTP

func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServerOption

type ServerOption func(*Server)

func ServerBefore

func ServerBefore(before ...RequestFunc) ServerOption

func SetConnCloseHandler

func SetConnCloseHandler(handler ConnectionCloseHandler) ServerOption

func SetSocketConfig

func SetSocketConfig(socketConfig ...SocketConfigFunc) ServerOption

type SocketConfigFunc

type SocketConfigFunc func(context.Context, *websocket.Conn)

type WebSocketEndpoint

type WebSocketEndpoint func(ctx context.Context) (ingress chan interface{}, egress chan interface{}, err error)

Jump to

Keyboard shortcuts

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