Documentation ¶
Index ¶
- Constants
- Variables
- func EmptyMethodInvalid(next jsonrpc.Handler) jsonrpc.Handler
- func GetLogger(ctx context.Context) *slog.Logger
- func GetReqID(ctx context.Context) string
- func HttpPathMethod(h jsonrpc.Handler) jsonrpc.Handler
- func HttpPathMethodPrefix(h jsonrpc.Handler) jsonrpc.Handler
- func Logger(next jsonrpc.Handler) jsonrpc.Handler
- func MethodReplacer(replacer *strings.Replacer) jsonrpc.Middleware
- func New(h jsonrpc.Handler) func(next jsonrpc.Handler) jsonrpc.Handler
- func NewLogger(logger *slog.Logger) func(next jsonrpc.Handler) jsonrpc.Handler
- func NextRequestID() uint64
- func PrintPrettyStack(rvr interface{})
- func Recoverer(next jsonrpc.Handler) jsonrpc.Handler
- func RequestID(next jsonrpc.Handler) jsonrpc.Handler
- func Use(h jsonrpc.Handler, mw ...jsonrpc.Middleware) jsonrpc.Handler
Constants ¶
const LoggerKey ctxKeyLogger = 76
RequestIDKey is the key that holds the unique request ID in a request context.
const RequestIDKey ctxKeyRequestID = 0
RequestIDKey is the key that holds the unique request ID in a request context.
Variables ¶
var IsTTY bool
var LegacyUnderscoreReplacer = MethodReplacer(strings.NewReplacer("_", "/"))
var RequestIDHeader = "X-Request-Id"
RequestIDHeader is the name of the jrpc Header which contains the request id. Exported so that it can be changed by developers
Functions ¶
func EmptyMethodInvalid ¶ added in v0.4.15
func GetReqID ¶
GetReqID returns a request ID from the given context if one is present. Returns the empty string if a request ID cannot be found.
func HttpPathMethodPrefix ¶ added in v0.4.17
func MethodReplacer ¶
func MethodReplacer(replacer *strings.Replacer) jsonrpc.Middleware
MethodReplacer will use the replacer on every method before handling
func NextRequestID ¶
func NextRequestID() uint64
NextRequestID generates the next request ID in the sequence.
func PrintPrettyStack ¶
func PrintPrettyStack(rvr interface{})
func Recoverer ¶
Recoverer is a middleware that recovers from panics, logs the panic (and a backtrace), and returns a jrpc 500 (Internal Server Error) status if possible. Recoverer prints a request ID if one is provided.
Alternatively, look at jrpcs://github.com/go-chi/jrpclog middleware pkgs.
func RequestID ¶
RequestID is a middleware that injects a request ID into the context of each request. A request ID is a string of the form "host.example.com/random-0001", where "random" is a base62 random string that uniquely identifies this go process, and where the last number is an atomically incremented request counter.
Types ¶
This section is empty.