Skip to content

Commit

Permalink
feat: support context interface for Context
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Sep 2, 2022
1 parent 9e15278 commit 1d15556
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ vendor
tmp
*.out
examples/*/go.sum
_book
_book
.vscode
16 changes: 16 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ const (
SignedCookieSuffix = ".sig"
)

func (c *Context) Deadline() (deadline time.Time, ok bool) {
return c.Context().Deadline()
}

func (c *Context) Done() <-chan struct{} {
return c.Context().Done()
}

func (c *Context) Err() error {
return c.Context().Err()
}

func (c *Context) Value(key interface{}) interface{} {
return c.Context().Value(key)
}

// Reset all fields of context
func (c *Context) Reset() {
c.Request = nil
Expand Down
1 change: 1 addition & 0 deletions elton.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ type (
)

var _ http.Handler = (*Elton)(nil)
var _ context.Context = (*Context)(nil)

// DefaultSkipper default skipper function
func DefaultSkipper(c *Context) bool {
Expand Down

0 comments on commit 1d15556

Please sign in to comment.