Browse Source

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.
Carl Jackson 12 years ago
parent
commit
33a3e80aa8
1 changed files with 4 additions and 5 deletions
  1. +4
    -5
      web/router.go

+ 4
- 5
web/router.go View File

@ -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) {


Loading…
Cancel
Save