diff --git a/mux.go b/mux.go index 26f9582a..449f9d62 100644 --- a/mux.go +++ b/mux.go @@ -361,9 +361,9 @@ func (r *Router) Walk(walkFn WalkFunc) error { return r.walk(walkFn, []*Route{}) } -// SkipRouter is used as a return value from WalkFuncs to indicate that the +// ErrSkipRouter is used as a return value from WalkFuncs to indicate that the // router that walk is about to descend down to should be skipped. -var SkipRouter = errors.New("skip this router") +var ErrSkipRouter = errors.New("skip this router") // WalkFunc is the type of the function called for each route visited by Walk. // At every invocation, it is given the current route, and the current router, @@ -373,7 +373,7 @@ type WalkFunc func(route *Route, router *Router, ancestors []*Route) error func (r *Router) walk(walkFn WalkFunc, ancestors []*Route) error { for _, t := range r.routes { err := walkFn(t, r, ancestors) - if err == SkipRouter { + if err == ErrSkipRouter { continue } if err != nil { diff --git a/mux_test.go b/mux_test.go index 9a740bb8..0255c9f5 100644 --- a/mux_test.go +++ b/mux_test.go @@ -1598,7 +1598,7 @@ func TestWalkSingleDepth(t *testing.T) { err := r0.Walk(func(route *Route, router *Router, ancestors []*Route) error { matcher := route.matchers[0].(*routeRegexp) if matcher.template == "/d" { - return SkipRouter + return ErrSkipRouter } if len(ancestors) != depths[i] { t.Errorf(`Expected depth of %d at i = %d; got "%d"`, depths[i], i, len(ancestors)) diff --git a/regexp.go b/regexp.go index 0293a928..b5a15ed9 100644 --- a/regexp.go +++ b/regexp.go @@ -181,16 +181,16 @@ func (r *routeRegexp) Match(req *http.Request, match *RouteMatch) bool { } } return r.regexp.MatchString(host) - } else { - if r.regexpType == regexpTypeQuery { - return r.matchQueryString(req) - } - path := req.URL.Path - if r.options.useEncodedPath { - path = req.URL.EscapedPath() - } - return r.regexp.MatchString(path) } + + if r.regexpType == regexpTypeQuery { + return r.matchQueryString(req) + } + path := req.URL.Path + if r.options.useEncodedPath { + path = req.URL.EscapedPath() + } + return r.regexp.MatchString(path) } // url builds a URL part using the given values.