[bugfix] Fix method subrouter handler matching (#300) (#317)

* Test method-based subrouters for multiple matching paths

* Pass TestMethodsSubrouter

* Change http.Method* constants to string literals
- Make compatible with Go v1.5

* Make TestMethodsSubrouter stateless and concurrent

* Remove t.Run and break up tests for concurrency

* Use backticks to remove quote escaping

* Remove global method handlers and HTTP method constants
This commit is contained in:
Matthew
2017-11-28 11:51:17 -08:00
committed by Kamil Kisiel
parent 2d5fef06b8
commit 4a3d4f3dd2
2 changed files with 314 additions and 0 deletions

View File

@@ -75,6 +75,8 @@ func (r *Route) Match(req *http.Request, match *RouteMatch) bool {
if match.MatchErr == ErrMethodMismatch {
// We found a route which matches request method, clear MatchErr
match.MatchErr = nil
// Then override the mis-matched handler
match.Handler = r.handler
}
// Yay, we have a match. Let's collect some info about it.