7a3d05eb by astaxie

when pattern is /admin while the url is /admin/ should return 200. fix #416

1 parent 4d7f7ffa
...@@ -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
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!