From 33a3e80aa83961f1125bf461f42419a8d3bf2f04 Mon Sep 17 00:00:00 2001 From: Carl Jackson Date: Sun, 4 May 2014 08:51:20 -0700 Subject: [PATCH] Fix routing behavior The fast routing diff introduced a regression with how method sets were calculated for routes that did not match. This fixes that behavior, as well as making routing considerably more memory-efficient (and therefore CPU-efficient too) for the case in which many routes share a prefix. --- web/router.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/web/router.go b/web/router.go index 6cf21e8..2d94d8f 100644 --- a/web/router.go +++ b/web/router.go @@ -144,16 +144,15 @@ type routeMachine struct { } func matchRoute(route route, m method, ms *method, r *http.Request, c *C) bool { - if !route.pattern.Match(r, c, false) { + if !route.pattern.Match(r, c, true) { return false } + *ms |= route.method if route.method&m != 0 { - return true - } else { - *ms |= route.method - return false + return route.pattern.Match(r, c, false) } + return false } func (rm routeMachine) route(c *C, w http.ResponseWriter, r *http.Request) (method, bool) {