From 39cff3481ca9e2726231c3067f58fcf3a8c9e333 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Wed, 5 Aug 2015 09:26:50 +0200 Subject: [PATCH] Add note about the availability of CurrentRoute. --- mux.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mux.go b/mux.go index e253230..4a94a23 100644 --- a/mux.go +++ b/mux.go @@ -312,6 +312,9 @@ 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. func CurrentRoute(r *http.Request) *Route { if rv := context.Get(r, routeKey); rv != nil { return rv.(*Route)