Skip to content

Commit

Permalink
drop the support for the core context
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangxue committed Sep 2, 2016
1 parent 9da0c60 commit 70e4c29
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
31 changes: 0 additions & 31 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
package routing

import (
"context"
"net/http"
"time"
)

// Context represents the contextual data and environment while processing an incoming HTTP request.
Expand All @@ -23,8 +21,6 @@ type Context struct {
writer DataWriter
}

var _ context.Context = &Context{}

// NewContext creates a new Context object with the given response, request, and the handlers.
// This method is primarily provided for writing unit tests for handlers.
func NewContext(res http.ResponseWriter, req *http.Request, handlers ...Handler) *Context {
Expand Down Expand Up @@ -168,33 +164,6 @@ func (c *Context) SetDataWriter(writer DataWriter) {
c.writer = writer
}

// Value is part of context.Context which returns the value corresponding to the specified key.
// If the key does not exist, nil will be returned. Only string-typed keys are supported.
func (c *Context) Value(key interface{}) interface{} {
if k, ok := key.(string); ok {
return c.Get(k)
}
return nil
}

// Deadline is part of context.Context.
// The default implementation simply returns nils.
func (c *Context) Deadline() (deadline time.Time, ok bool) {
return
}

// Done is part of context.Context.
// The default implementation simply returns nil.
func (c *Context) Done() <-chan struct{} {
return nil
}

// Err is part of context.Context.
// The default implementation simply returns nil.
func (c *Context) Err() error {
return nil
}

// init sets the request and response of the context and resets all other properties.
func (c *Context) init(response http.ResponseWriter, request *http.Request) {
c.Response = response
Expand Down
8 changes: 0 additions & 8 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ func TestContextGetSet(t *testing.T) {
c.Set("xyz", 123)
assert.Equal(t, "123", c.Get("abc").(string))
assert.Equal(t, 123, c.Get("xyz").(int))
assert.Equal(t, "123", c.Value("abc"))
assert.Nil(t, c.Value("abcd"))
assert.Nil(t, c.Value(123))
deadline, ok := c.Deadline()
assert.Zero(t, deadline)
assert.False(t, ok)
assert.Nil(t, c.Done())
assert.Nil(t, c.Err())
}

func TestContextQueryForm(t *testing.T) {
Expand Down

0 comments on commit 70e4c29

Please sign in to comment.