Documentation
¶
Index ¶
- Constants
- func AcceptConnection(next http.Handler) http.Handler
- func AddLogField(ctx context.Context, k string, v string)
- func CancelConnection(ctx context.Context, err error)
- func CopyHeader(dst, src http.Header)
- func DenyRPCMethods(methods []string) func(http.Handler) http.Handler
- func EndpointProvider(prov endpoint.Provider) func(http.Handler) http.Handler
- func GetAssignedUpstream(ctx context.Context) string
- func GetClientConnection(ctx context.Context) *websocket.Conn
- func GetClientConnectionContext(ctx context.Context) context.Context
- func GetClientConnectionType(ctx context.Context) string
- func GetConnectionID(ctx context.Context) string
- func GetEndpointProvider(ctx context.Context) endpoint.Provider
- func GetJsonRPCFrame(ctx context.Context) *dto.RPCFrame
- func GetLogField(ctx context.Context, k string) string
- func GetLogger(ctx context.Context) *logrus.Logger
- func GetRPCMethod(ctx context.Context) string
- func GetRPCRequestID(ctx context.Context) int
- func IsWebsocket(r *http.Request) bool
- func JsonRPC(opts ...JsonRPCMiddlewareOption) func(http.Handler) http.Handler
- func LogRequestDetails(r *http.Request)
- func LogSubscriptionDetails(ctx context.Context, client string, upstream string, f dto.RPCFrame)
- func Logger(l *logrus.Logger, opts ...LoggerOption) func(http.Handler) http.Handler
- func ThrottleWithOpts(opts ThrottleOpts) func(http.Handler) http.Handler
- func WithContextValue(r *http.Request, key any, v any) *http.Request
- func WithNewBody(r *http.Request, b []byte) *http.Request
- type ErrorResponse
- type HttpMetrics
- type InMemoryWriter
- type JsonRPCMiddleware
- type JsonRPCMiddlewareOption
- type LoggerOption
- type RPCMiddleware
- type ThrottleOpts
- type WrapedWSWriter
Constants ¶
View Source
const ( ContextKeyUstreamProvider = contextKey("UpstreamProvider") ContextKeyUstreamAddr = contextKey("UpstreamAddr") LogFieldsCtxKey = contextKey("LogFields") LogWithParamsCtxKey = contextKey("LogWithParams") LogWithIgnoreMethodsCtxKey = contextKey("LogWithIgnoreMethods") LogRequestStartTime = contextKey("LogRequestStartTime") LogLoggerCtxKey = contextKey("LogLogger") RPCPayloadCtxKey = contextKey("RPCPayload") RPCMethodCtxKey = contextKey("RPCMethod") RPCRequestID = contextKey("RPCRequestID") RPCMiddlewareCtxKey = contextKey("RPCMiddleware") ConnectionTypeCtxKey = contextKey("ConnectionType") ConnectionParentCtxKey = contextKey("ConnectionParentContext") ConnectionClientWSCtxKey = contextKey("ConnectionClientWS") ConnectionClientIDCtxKey = contextKey("ConnectionClientID") ConnectionClientCancelCtxKey = contextKey("ConnectionClientCancel") )
View Source
const ( ConnectionTypeWebsocketCtx = "websocket" ConnectionTypeHTTPCtx = "http" RPCPayloadTypeBatchCtx = "batch" RPCPayloadTypeFrameCtx = "frame" )
Variables ¶
This section is empty.
Functions ¶
func CancelConnection ¶ added in v0.0.4
func CopyHeader ¶
func EndpointProvider ¶
func GetAssignedUpstream ¶
func GetClientConnection ¶ added in v0.1.0
func GetClientConnectionContext ¶ added in v0.1.0
func GetClientConnectionType ¶
func GetConnectionID ¶
func GetRPCMethod ¶
func GetRPCRequestID ¶
func IsWebsocket ¶
func LogRequestDetails ¶
func LogSubscriptionDetails ¶
func ThrottleWithOpts ¶
func ThrottleWithOpts(opts ThrottleOpts) func(http.Handler) http.Handler
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Err error `json:"-"` HTTPStatusCode int `json:"-"` StatusText string `json:"status"` ErrorText string `json:"error,omitempty"` }
func ErrorBadGateway ¶
func ErrorBadGateway(err error) *ErrorResponse
func ErrorInternalServer ¶
func ErrorInternalServer(err error) *ErrorResponse
func ErrorInvalidRequest ¶
func ErrorInvalidRequest(err error) *ErrorResponse
func (*ErrorResponse) Render ¶
func (e *ErrorResponse) Render(w http.ResponseWriter, r *http.Request) error
type HttpMetrics ¶
type HttpMetrics struct {
// contains filtered or unexported fields
}
func (*HttpMetrics) GetMonitoringEventTypes ¶
func (m *HttpMetrics) GetMonitoringEventTypes() []string
func (*HttpMetrics) Middleware ¶
func (m *HttpMetrics) Middleware() func(http.Handler) http.Handler
func (*HttpMetrics) SetObserver ¶
func (m *HttpMetrics) SetObserver(mon monitoring.Observer)
type InMemoryWriter ¶
func NewInMemoryWriter ¶
func NewInMemoryWriter(w http.ResponseWriter) *InMemoryWriter
func (*InMemoryWriter) Header ¶
func (w *InMemoryWriter) Header() http.Header
func (*InMemoryWriter) WriteHeader ¶
func (w *InMemoryWriter) WriteHeader(statusCode int)
type JsonRPCMiddleware ¶
type JsonRPCMiddleware struct { }
func GetJsonRPCMiddleware ¶
func GetJsonRPCMiddleware(ctx context.Context) *JsonRPCMiddleware
func (*JsonRPCMiddleware) NewFrameContext ¶
func (*JsonRPCMiddleware) ParsePayload ¶
func (m *JsonRPCMiddleware) ParsePayload(payload []byte) interface{}
type JsonRPCMiddlewareOption ¶ added in v0.0.4
type LoggerOption ¶ added in v0.1.0
func LogWithIgnoreMethods ¶ added in v0.1.0
func LogWithIgnoreMethods(methods []string) LoggerOption
func LogWithParams ¶ added in v0.1.0
func LogWithParams() LoggerOption
type RPCMiddleware ¶
type RPCMiddleware interface {
ParsePayload(payload []byte) interface{}
}
type ThrottleOpts ¶
type ThrottleOpts struct { Limit int BacklogLimit int Context context.Context BacklogTimeout time.Duration Observer monitoring.Observer }
ThrottleOpts represents a set of throttling options.
type WrapedWSWriter ¶
type WrapedWSWriter struct {
// contains filtered or unexported fields
}
func (*WrapedWSWriter) Header ¶
func (w *WrapedWSWriter) Header() http.Header
func (*WrapedWSWriter) WriteHeader ¶
func (w *WrapedWSWriter) WriteHeader(statusCode int)
Click to show internal directories.
Click to hide internal directories.