diff --git a/mux.go b/mux.go index eb03d48d..eaff897a 100644 --- a/mux.go +++ b/mux.go @@ -286,6 +286,15 @@ func (r *Router) OmitRouteFromContext(value bool) *Router { return r } +// OmitRouterFromContext defines the behavior of omitting the Router from the +// http.Request context. +// +// RouterFromRequest will yield nil with this option. +func (r *Router) OmitRouterFromContext(value bool) *Router { + r.omitRouterFromContext = value + return r +} + // UseEncodedPath tells the router to match the encoded original path // to the routes. // For eg. "/path/foo%2Fbar/to" will match the path "/path/{var}/to". diff --git a/mux_test.go b/mux_test.go index 0845d7f7..b078f5f8 100644 --- a/mux_test.go +++ b/mux_test.go @@ -1768,6 +1768,10 @@ func TestPanicOnCapturingGroups(t *testing.T) { NewRouter().NewRoute().Path("/{type:(promo|special)}/{promoId}.json") } +func TestRouterInContext(t *testing.T) { + // TODO Write tests for router in context +} + // ---------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------