remove redundant code that remove support gorilla/context (#427)
* remove redundant code that remove support gorilla/context * backward compatible for remove redundant code
This commit is contained in:
committed by
Matt Silverlock
parent
d2b5d13b92
commit
6137e193cd
@@ -16,7 +16,3 @@ func contextSet(r *http.Request, key, val interface{}) *http.Request {
|
|||||||
|
|
||||||
return r.WithContext(context.WithValue(r.Context(), key, val))
|
return r.WithContext(context.WithValue(r.Context(), key, val))
|
||||||
}
|
}
|
||||||
|
|
||||||
func contextClear(r *http.Request) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
9
mux.go
9
mux.go
@@ -22,7 +22,7 @@ var (
|
|||||||
|
|
||||||
// NewRouter returns a new router instance.
|
// NewRouter returns a new router instance.
|
||||||
func NewRouter() *Router {
|
func NewRouter() *Router {
|
||||||
return &Router{namedRoutes: make(map[string]*Route), KeepContext: false}
|
return &Router{namedRoutes: make(map[string]*Route)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Router registers routes to be matched and dispatches a handler.
|
// Router registers routes to be matched and dispatches a handler.
|
||||||
@@ -57,7 +57,8 @@ type Router struct {
|
|||||||
namedRoutes map[string]*Route
|
namedRoutes map[string]*Route
|
||||||
|
|
||||||
// If true, do not clear the request context after handling the request.
|
// If true, do not clear the request context after handling the request.
|
||||||
// This has no effect when go1.7+ is used, since the context is stored
|
//
|
||||||
|
// Deprecated: No effect when go1.7+ is used, since the context is stored
|
||||||
// on the request itself.
|
// on the request itself.
|
||||||
KeepContext bool
|
KeepContext bool
|
||||||
|
|
||||||
@@ -208,10 +209,6 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
handler = http.NotFoundHandler()
|
handler = http.NotFoundHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !r.KeepContext {
|
|
||||||
defer contextClear(req)
|
|
||||||
}
|
|
||||||
|
|
||||||
handler.ServeHTTP(w, req)
|
handler.ServeHTTP(w, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user