Skip to content

Commit 6137e19

Browse files
alimyelithrar
authored andcommitted
remove redundant code that remove support gorilla/context (#427)
* remove redundant code that remove support gorilla/context * backward compatible for remove redundant code
1 parent d2b5d13 commit 6137e19

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

context.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,3 @@ func contextSet(r *http.Request, key, val interface{}) *http.Request {
1616

1717
return r.WithContext(context.WithValue(r.Context(), key, val))
1818
}
19-
20-
func contextClear(r *http.Request) {
21-
return
22-
}

mux.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222

2323
// NewRouter returns a new router instance.
2424
func NewRouter() *Router {
25-
return &Router{namedRoutes: make(map[string]*Route), KeepContext: false}
25+
return &Router{namedRoutes: make(map[string]*Route)}
2626
}
2727

2828
// Router registers routes to be matched and dispatches a handler.
@@ -57,7 +57,8 @@ type Router struct {
5757
namedRoutes map[string]*Route
5858

5959
// If true, do not clear the request context after handling the request.
60-
// This has no effect when go1.7+ is used, since the context is stored
60+
//
61+
// Deprecated: No effect when go1.7+ is used, since the context is stored
6162
// on the request itself.
6263
KeepContext bool
6364

@@ -208,10 +209,6 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
208209
handler = http.NotFoundHandler()
209210
}
210211

211-
if !r.KeepContext {
212-
defer contextClear(req)
213-
}
214-
215212
handler.ServeHTTP(w, req)
216213
}
217214

0 commit comments

Comments
 (0)