From 2d85e33ef68380f936bea62cd710208088f52011 Mon Sep 17 00:00:00 2001 From: Andreas Jaekle Date: Fri, 23 Aug 2019 14:09:14 +0200 Subject: [PATCH] fix broken gin.Context go.Context implementation --- context.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/context.go b/context.go index d9fcc285..d8263ab9 100644 --- a/context.go +++ b/context.go @@ -1038,14 +1038,14 @@ func (c *Context) SetAccepted(formats ...string) { // should be canceled. Deadline returns ok==false when no deadline is // set. Successive calls to Deadline return the same results. func (c *Context) Deadline() (deadline time.Time, ok bool) { - return + return c.Request.Context().Deadline() } // Done returns a channel that's closed when work done on behalf of this // context should be canceled. Done may return nil if this context can // never be canceled. Successive calls to Done return the same value. func (c *Context) Done() <-chan struct{} { - return nil + return c.Request.Context().Done() } // Err returns a non-nil error value after Done is closed, @@ -1055,7 +1055,7 @@ func (c *Context) Done() <-chan struct{} { // Canceled if the context was canceled // or DeadlineExceeded if the context's deadline passed. func (c *Context) Err() error { - return nil + return c.Request.Context().Err() } // Value returns the value associated with this context for key, or nil @@ -1066,8 +1066,9 @@ func (c *Context) Value(key interface{}) interface{} { return c.Request } if keyAsString, ok := key.(string); ok { - val, _ := c.Get(keyAsString) - return val + if val, ok := c.Get(keyAsString); ok { + return val + } } - return nil + return c.Request.Context().Value(key) }