Documentation ¶
Index ¶
- Constants
- func GetRequestTimeout(r *http.Request, defaultRequestTimeout time.Duration) (time.Duration, error)
- func HttpNotifyHandler(ctx context.Context, handler http.HandlerFunc, event []byte, codec HttpCodec, ...) error
- func HttpRequestHandler(ctx context.Context, handler http.HandlerFunc, event []byte, codec HttpCodec, ...) ([]byte, error)
- func NewProxyHandler(codec HttpCodec, opts ...ProxyHandlerOption) ws.ProxyHandler
- func NewRecoveryHandler(target ws.EventHandler, logger *slog.Logger) ws.EventHandler
- func ProxyHttpRequest(conn *ws.Conn, w http.ResponseWriter, r *http.Request, codec HttpCodec, ...) error
- type HTTPHandler
- type HTTPHandlerOption
- type HttpCodec
- type ProxyHandlerOption
Constants ¶
View Source
const ( HeaderRequestTimeout = "x-backstream-request-timeout" DefaultRequestTimeout = 3 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func GetRequestTimeout ¶
func HttpNotifyHandler ¶
func HttpRequestHandler ¶
func NewProxyHandler ¶
func NewProxyHandler(codec HttpCodec, opts ...ProxyHandlerOption) ws.ProxyHandler
func NewRecoveryHandler ¶
func NewRecoveryHandler(target ws.EventHandler, logger *slog.Logger) ws.EventHandler
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 ¶
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
Click to show internal directories.
Click to hide internal directories.