dispatch

package module
v0.0.0-...-682361c Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterImplementationToNegotiator

func RegisterImplementationToNegotiator[O any](ctn *ContentTypeNegotiator, contentType string) error

Types

type ContentTypeHandler

type ContentTypeHandler[R RequestAdapter, O any] func(r R) (O, error)

func (ContentTypeHandler[R, O]) AsTypedHandler

func (fn ContentTypeHandler[R, O]) AsTypedHandler(ctn *ContentTypeNegotiator, logger io.Writer) typedHandler[R]

type ContentTypeNegotiator

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

type ContentTypeNegotiator map[string]map[string]reflect.Type

func NewContentTypeNegotiator

func NewContentTypeNegotiator() *ContentTypeNegotiator

type HttpError

type HttpError interface {
	error
	ErrorCode() int
}

type Middleware

type Middleware[T RequestAdapter] func(w http.ResponseWriter, r T, next Middleware[T])

type NegotiatorImplementationError

type NegotiatorImplementationError byte
const (
	InvalidContentType NegotiatorImplementationError
	InvalidImplementation
	InvalidInterfaceDefinition
)

func (NegotiatorImplementationError) Error

type ProtocolRouter

type ProtocolRouter[R RequestAdapter] struct {
	Http             typedHandler[R]
	WebSocket        func(r R, in <-chan WebSocketMessage) <-chan WebSocketMessage
	ServerSentEvents func(r R, ctx context.Context) <-chan ServerSentEventMessage
}

func (*ProtocolRouter[R]) AsTypedHandler

func (proto *ProtocolRouter[R]) AsTypedHandler(logger io.Writer) typedHandler[R]

type RequestAdapter

type RequestAdapter interface {
	Request() *http.Request
}

type Server

type Server struct {
	*http.ServeMux
	*http.Server
}

func NewServer

func NewServer() *Server

type ServerSentEventMessage

type ServerSentEventMessage struct {
	Event string
	Data  []byte
}

type TypedHandler

type TypedHandler[T RequestAdapter] struct {
	*http.ServeMux
	// contains filtered or unexported fields
}

func NewTypedHandler

func NewTypedHandler[T RequestAdapter](fn func(*http.Request) T) *TypedHandler[T]

func (*TypedHandler[T]) HandleFunc

func (mux *TypedHandler[T]) HandleFunc(route string, handler typedHandler[T])

func (*TypedHandler[T]) UseMiddleware

func (mux *TypedHandler[T]) UseMiddleware(mws ...Middleware[T])

type WSMessageType

type WSMessageType byte
const (
	WSText WSMessageType
	WSBinary
)

type WebSocketMessage

type WebSocketMessage struct {
	Data []byte
	Type WSMessageType
}

func WebSocketBinaryMessage

func WebSocketBinaryMessage(msg []byte) WebSocketMessage

func WebSocketTextMessage

func WebSocketTextMessage(msg string) WebSocketMessage

Directories

Path Synopsis
examples
basic command

Jump to

Keyboard shortcuts

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