Skip to content

Commit

Permalink
Renamed Context#Context => Context#StdContext & Context#SetContext to…
Browse files Browse the repository at this point in the history
… ContextSetStdContext, 2d772e0

Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed Sep 9, 2016
1 parent 2d772e0 commit 00699ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 00699ed

Please sign in to comment.