when pattern is /admin while the url is /admin/ should return 200. fix #416
Showing
1 changed file
with
9 additions
and
1 deletions
| ... | @@ -573,13 +573,21 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -573,13 +573,21 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 573 | break | 573 | break |
| 574 | } | 574 | } |
| 575 | } | 575 | } |
| 576 | // pattern /admin url /admin 200 /admin/ 404 | 576 | // pattern /admin url /admin 200 /admin/ 200 |
| 577 | // pattern /admin/ url /admin 301 /admin/ 200 | 577 | // pattern /admin/ url /admin 301 /admin/ 200 |
| 578 | if requestPath[n-1] != '/' && len(route.pattern) == n+1 && | 578 | if requestPath[n-1] != '/' && len(route.pattern) == n+1 && |
| 579 | route.pattern[n] == '/' && route.pattern[:n] == requestPath { | 579 | route.pattern[n] == '/' && route.pattern[:n] == requestPath { |
| 580 | http.Redirect(w, r, requestPath+"/", 301) | 580 | http.Redirect(w, r, requestPath+"/", 301) |
| 581 | goto Admin | 581 | goto Admin |
| 582 | } | 582 | } |
| 583 | if n >= 1 && requestPath[:n-1] == route.pattern { | ||
| 584 | runMethod = p.getRunMethod(r.Method, context, route) | ||
| 585 | if runMethod != "" { | ||
| 586 | runrouter = route.controllerType | ||
| 587 | findrouter = true | ||
| 588 | break | ||
| 589 | } | ||
| 590 | } | ||
| 583 | } | 591 | } |
| 584 | 592 | ||
| 585 | //find regex's router | 593 | //find regex's router | ... | ... |
-
Please register or sign in to post a comment