From fe14465e50778b54b9bfafc6995fd237ea5afb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corn=C3=A9=20de=20Jong?= <5366568-cornedejong@users.noreply.gitlab.com> Date: Tue, 28 May 2024 21:36:01 +0200 Subject: [PATCH] added conf method and defined initial test func --- mux.go | 9 +++++++++ mux_test.go | 4 ++++ 2 files changed, 13 insertions(+) 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 // ----------------------------------------------------------------------------