MCPcopy
hub / github.com/nats-io/nats.go / ContextHandler

Function ContextHandler

micro/request.go:96–100  ·  view source on GitHub ↗

ContextHandler is a helper function used to utilize [context.Context] in request handlers.

(ctx context.Context, handler func(context.Context, Request))

Source from the content-addressed store, hash-verified

94// ContextHandler is a helper function used to utilize [context.Context]
95// in request handlers.
96func ContextHandler(ctx context.Context, handler func(context.Context, Request)) Handler {
97 return HandlerFunc(func(req Request) {
98 handler(ctx, req)
99 })
100}
101
102// Respond sends the response for the request.
103// Additional headers can be passed using [WithHeaders] option.

Callers 3

ExampleContextHandlerFunction · 0.92
TestContextHandlerFunction · 0.92

Calls 1

HandlerFuncFuncType · 0.85

Tested by 3

ExampleContextHandlerFunction · 0.74
TestContextHandlerFunction · 0.74