handler

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderRequestTimeout  = "x-backstream-request-timeout"
	DefaultRequestTimeout = 3 * time.Second
)

Variables

This section is empty.

Functions

func GetRequestTimeout

func GetRequestTimeout(r *http.Request, defaultRequestTimeout time.Duration) (time.Duration, error)

func HttpNotifyHandler

func HttpNotifyHandler(ctx context.Context, handler http.HandlerFunc, event []byte, codec HttpCodec, defaultRequestTimeout time.Duration) error

func HttpRequestHandler

func HttpRequestHandler(ctx context.Context, handler http.HandlerFunc, event []byte, codec HttpCodec, defaultRequestTimeout time.Duration) ([]byte, error)

func NewProxyHandler

func NewProxyHandler(codec HttpCodec, opts ...ProxyHandlerOption) ws.ProxyHandler

func NewRecoveryHandler

func NewRecoveryHandler(target ws.EventHandler, logger *slog.Logger) ws.EventHandler

func ProxyHttpRequest

func ProxyHttpRequest(conn *ws.Conn, w http.ResponseWriter, r *http.Request, codec HttpCodec, defaultRequestTimeout time.Duration) error

Types

type HTTPHandler

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

func NewHTTPHandler

func NewHTTPHandler(handlerFunc http.HandlerFunc, codec HttpCodec, opts ...HTTPHandlerOption) *HTTPHandler

func (*HTTPHandler) HandleNotify

func (h *HTTPHandler) HandleNotify(ctx context.Context, event []byte) error

func (*HTTPHandler) HandleRequest

func (h *HTTPHandler) HandleRequest(ctx context.Context, event []byte) ([]byte, error)

type HTTPHandlerOption

type HTTPHandlerOption func(*HTTPHandler)

func WithHTTPDefaultRequestTimeout

func WithHTTPDefaultRequestTimeout(timeout time.Duration) HTTPHandlerOption

type HttpCodec

type HttpCodec interface {
	RequestCodec() ws.Codec[*message.EventHTTPRequest]
	ResponseCodec() ws.Codec[*message.EventHTTPResponse]
	MessageCodec() ws.Codec[*message.Message]
}

func NewHttpJsonCodec

func NewHttpJsonCodec() HttpCodec

func NewHttpProtoCodec

func NewHttpProtoCodec() HttpCodec

type ProxyHandlerOption

type ProxyHandlerOption func(*proxyHandler)

func WithProxyDefaultRequestTimeout

func WithProxyDefaultRequestTimeout(timeout time.Duration) ProxyHandlerOption

Jump to

Keyboard shortcuts

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