From 16bead4007c61f31e8d431fcedea13966b13d991 Mon Sep 17 00:00:00 2001 From: RaviKiran Kilingar Date: Tue, 26 Jan 2021 21:40:50 +0530 Subject: [PATCH] Removes line as use case is covered by #422 --- route.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/route.go b/route.go index d5afa46..330cf0a 100644 --- a/route.go +++ b/route.go @@ -74,13 +74,14 @@ func (r *Route) Match(req *http.Request, match *RouteMatch) bool { return false } + // If a route matches, but the HTTP method does not, we do one of two (2) things: + // 1. Reset the match error if we find a matching method later. + // 2. Else, we override the matched handler in the event we have a possible fallback handler for that route. + // + // This prevents propagation of ErrMethodMismatch once a suitable match is found for a Method-Path combination if match.MatchErr == ErrMethodMismatch { // We found a route which matches request method, clear MatchErr match.MatchErr = nil - // Then override the mis-matched handler - if r.handler != nil { - match.Handler = r.handler - } } // Yay, we have a match. Let's collect some info about it.