aboutsummaryrefslogtreecommitdiffstats
path: root/modules/context
diff options
context:
space:
mode:
Diffstat (limited to 'modules/context')
-rw-r--r--modules/context/context.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index d812d7b58c..d45e9ff87c 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -509,7 +509,7 @@ func (ctx *Context) ParamsInt64(p string) int64 {
// SetParams set params into routes
func (ctx *Context) SetParams(k, v string) {
- chiCtx := chi.RouteContext(ctx.Req.Context())
+ chiCtx := chi.RouteContext(ctx)
chiCtx.URLParams.Add(strings.TrimPrefix(k, ":"), url.PathEscape(v))
}
@@ -528,6 +528,26 @@ func (ctx *Context) Status(status int) {
ctx.Resp.WriteHeader(status)
}
+// Deadline is part of the interface for context.Context and we pass this to the request context
+func (ctx *Context) Deadline() (deadline time.Time, ok bool) {
+ return ctx.Req.Context().Deadline()
+}
+
+// Done is part of the interface for context.Context and we pass this to the request context
+func (ctx *Context) Done() <-chan struct{} {
+ return ctx.Req.Context().Done()
+}
+
+// Err is part of the interface for context.Context and we pass this to the request context
+func (ctx *Context) Err() error {
+ return ctx.Req.Context().Err()
+}
+
+// Value is part of the interface for context.Context and we pass this to the request context
+func (ctx *Context) Value(key interface{}) interface{} {
+ return ctx.Req.Context().Value(key)
+}
+
// Handler represents a custom handler
type Handler func(*Context)