Skip to content

Commit ab1af21

Browse files
committed
Make modules/context.Context a context.Context
Signed-off-by: Andrew Thornton <[email protected]>
1 parent effad26 commit ab1af21

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

modules/context/context.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,26 @@ func (ctx *Context) Status(status int) {
528528
ctx.Resp.WriteHeader(status)
529529
}
530530

531+
// Deadline is part of the interface for context.Context and we pass this to the request context
532+
func (ctx *Context) Deadline() (deadline time.Time, ok bool) {
533+
return ctx.Req.Context().Deadline()
534+
}
535+
536+
// Done is part of the interface for context.Context and we pass this to the request context
537+
func (ctx *Context) Done() <-chan struct{} {
538+
return ctx.Req.Context().Done()
539+
}
540+
541+
// Err is part of the interface for context.Context and we pass this to the request context
542+
func (ctx *Context) Err() error {
543+
return ctx.Req.Context().Err()
544+
}
545+
546+
// Value is part of the interface for context.Context and we pass this to the request context
547+
func (ctx *Context) Value(key interface{}) interface{} {
548+
return ctx.Req.Context().Value(key)
549+
}
550+
531551
// Handler represents a custom handler
532552
type Handler func(*Context)
533553

0 commit comments

Comments
 (0)