ContextHandler is a helper function used to utilize [context.Context] in request handlers.
(ctx context.Context, handler func(context.Context, Request))
| 94 | // ContextHandler is a helper function used to utilize [context.Context] |
| 95 | // in request handlers. |
| 96 | func 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. |