websocket

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoding

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

type Handler

type Handler interface {
	// contains filtered or unexported methods
}

type IReplier

type IReplier[T any, R any] interface {
	Apply(ctx context.Context, req R) error
	Reply(ctx context.Context) (T, error)
	Close(ctx context.Context) error
}

type IServerOption

type IServerOption interface {
	// contains filtered or unexported methods
}

func WithHandlerBuilders

func WithHandlerBuilders(handlerBuilders ...IWSHandlerBuilder) IServerOption

type IWSHandlerBuilder

type IWSHandlerBuilder interface {
	Build(ctx context.Context) (Handler, error)
	Path() string
}

type IWSOption

type IWSOption interface {
	// contains filtered or unexported methods
}

type Server

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

func NewServer

func NewServer(addr string, opts ...IServerOption) (*Server, error)

func (*Server) Start

func (x *Server) Start(ctx context.Context) error

func (*Server) Stop

func (x *Server) Stop(ctx context.Context) error

type ServerOptionFunc

type ServerOptionFunc func(*ServerOptions)

func WithServerOptionErrorEncodeFunc

func WithServerOptionErrorEncodeFunc(fn func(w http.ResponseWriter, err error)) ServerOptionFunc

type ServerOptions

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

type WSMiddlewareFunc

type WSMiddlewareFunc func(WSPreHandleFunc) WSPreHandleFunc

type WSOptionFunc

type WSOptionFunc func(*WSOptions)

func WithErrorEncodeFunc

func WithErrorEncodeFunc(fn func(w http.ResponseWriter, err error)) WSOptionFunc

func WithReplyEncodeFunc

func WithReplyEncodeFunc(fn func(ws *websocket.Conn, resp interface{})) WSOptionFunc

func WithReplyErrorEncodeFunc

func WithReplyErrorEncodeFunc(fn func(ws *websocket.Conn, err error)) WSOptionFunc

func WithRequestDecodeFunc

func WithRequestDecodeFunc(fn func(r *http.Request, req interface{}) error) WSOptionFunc

func WithResponseEncodeFunc

func WithResponseEncodeFunc(fn func(w http.ResponseWriter, resp interface{})) WSOptionFunc

func WithWSMiddlewareFunc

func WithWSMiddlewareFunc(fns ...WSMiddlewareFunc) WSOptionFunc

type WSOptions

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

type WSPreHandleFunc

type WSPreHandleFunc func(context.Context, *http.Request) error

type WebSocket

type WebSocket[T any, R any] struct {
	// contains filtered or unexported fields
}

func NewWebSocket

func NewWebSocket[T any, R any](replier IReplier[T, R], opts ...IWSOption) *WebSocket[T, R]

Jump to

Keyboard shortcuts

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