Browse Source

Update comment and specify KeepContext option.

Orne Brocaar 11 years ago
parent
commit
13c8226081
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      mux.go

+ 4
- 3
mux.go View File

@ -312,9 +312,10 @@ func Vars(r *http.Request) map[string]string {
}
// CurrentRoute returns the matched route for the current request, if any.
// Note: this only works when called inside the handler of the matched route
// because it uses context.Get() which will be cleared after executing the
// handler.
// This only works when called inside the handler of the matched route
// because the matched route is stored in the request context which is cleared
// after the handler returns, unless the KeepContext option is set on the
// Router.
func CurrentRoute(r *http.Request) *Route {
if rv := context.Get(r, routeKey); rv != nil {
return rv.(*Route)


Loading…
Cancel
Save