Documentation
¶
Index ¶
- func RegisterImplementationToNegotiator[O any](ctn *ContentTypeNegotiator, contentType string) error
- type ContentTypeHandler
- type ContentTypeNegotiator
- type HttpError
- type Middleware
- type NegotiatorImplementationError
- type ProtocolRouter
- type RequestAdapter
- type Server
- type ServerSentEventMessage
- type TypedHandler
- type WSMessageType
- type WebSocketMessage
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 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 ¶
func (e NegotiatorImplementationError) Error() string
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 ServerSentEventMessage ¶
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 WebSocketMessage ¶
type WebSocketMessage struct {
Data []byte
Type WSMessageType
}
func WebSocketBinaryMessage ¶
func WebSocketBinaryMessage(msg []byte) WebSocketMessage
func WebSocketTextMessage ¶
func WebSocketTextMessage(msg string) WebSocketMessage
Source Files
¶
Click to show internal directories.
Click to hide internal directories.