Context returns a context implementation that was set by user earlier or returns a non-nil, empty context, if it was not set earlier.
()
| 132 | // Context returns a context implementation that was set by |
| 133 | // user earlier or returns a non-nil, empty context, if it was not set earlier. |
| 134 | func (c *DefaultCtx) Context() context.Context { |
| 135 | if c.fasthttp == nil { |
| 136 | return context.Background() |
| 137 | } |
| 138 | if ctx, ok := c.fasthttp.UserValue(userContextKey).(context.Context); ok && ctx != nil { |
| 139 | return ctx |
| 140 | } |
| 141 | ctx := context.Background() |
| 142 | c.SetContext(ctx) |
| 143 | return ctx |
| 144 | } |
| 145 | |
| 146 | // SetContext sets a context implementation by user. |
| 147 | func (c *DefaultCtx) SetContext(ctx context.Context) { |
no test coverage detected