1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-28 08:38:39 +02:00

Renamed Context#Context => Context#StdContext & Context#SetContext to ContextSetStdContext, 2d772e02ca

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-09-09 11:47:43 -07:00
parent 2d772e02ca
commit 00699ed0db
2 changed files with 12 additions and 5 deletions

View File

@ -26,8 +26,11 @@ type (
Context interface {
context.Context
// SetContext sets `context.Context`.
SetContext(context.Context)
// StdContext returns `context.Context`.
StdContext() context.Context
// SetStdContext sets `context.Context`.
SetStdContext(context.Context)
// Request returns `engine.Request` interface.
Request() engine.Request
@ -190,7 +193,11 @@ const (
indexPage = "index.html"
)
func (c *echoContext) SetContext(ctx context.Context) {
func (c *echoContext) StdContext() context.Context {
return c.context
}
func (c *echoContext) SetStdContext(ctx context.Context) {
c.context = ctx
}

View File

@ -343,11 +343,11 @@ func TestContextRedirect(t *testing.T) {
func TestContextEmbedded(t *testing.T) {
var c Context
c = new(echoContext)
c.SetContext(context.WithValue(c, "key", "val"))
c.SetStdContext(context.WithValue(c, "key", "val"))
assert.Equal(t, "val", c.Value("key"))
now := time.Now()
ctx, _ := context.WithDeadline(context.Background(), now)
c.SetContext(ctx)
c.SetStdContext(ctx)
n, _ := ctx.Deadline()
assert.Equal(t, now, n)
assert.Equal(t, context.DeadlineExceeded, c.Err())