235d2740 by astaxie

Merge pull request #397 from pengfei-xue/devel

fix routing bug
2 parents 7aa307bd 00020139
...@@ -574,10 +574,12 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -574,10 +574,12 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
574 n := len(requestPath) 574 n := len(requestPath)
575 if requestPath == route.pattern { 575 if requestPath == route.pattern {
576 runrouter = route.controllerType 576 runrouter = route.controllerType
577 findrouter = true
578 runMethod = p.getRunMethod(r.Method, context, route) 577 runMethod = p.getRunMethod(r.Method, context, route)
578 if runMethod != "" {
579 findrouter = true
579 break 580 break
580 } 581 }
582 }
581 // pattern /admin url /admin 200 /admin/ 404 583 // pattern /admin url /admin 200 /admin/ 404
582 // pattern /admin/ url /admin 301 /admin/ 200 584 // pattern /admin/ url /admin 301 /admin/ 200
583 if requestPath[n-1] != '/' && len(route.pattern) == n+1 && 585 if requestPath[n-1] != '/' && len(route.pattern) == n+1 &&
...@@ -616,12 +618,14 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -616,12 +618,14 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
616 r.URL.RawQuery = url.Values(values).Encode() 618 r.URL.RawQuery = url.Values(values).Encode()
617 } 619 }
618 runrouter = route.controllerType 620 runrouter = route.controllerType
619 findrouter = true
620 context.Input.Params = params 621 context.Input.Params = params
621 runMethod = p.getRunMethod(r.Method, context, route) 622 runMethod = p.getRunMethod(r.Method, context, route)
623 if runMethod != "" {
624 findrouter = true
622 break 625 break
623 } 626 }
624 } 627 }
628 }
625 629
626 if !findrouter && p.enableAuto { 630 if !findrouter && p.enableAuto {
627 // deal with url with diffirent ext 631 // deal with url with diffirent ext
...@@ -801,9 +805,8 @@ func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Con ...@@ -801,9 +805,8 @@ func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Con
801 return m 805 return m
802 } else if m, ok = router.methods["*"]; ok { 806 } else if m, ok = router.methods["*"]; ok {
803 return m 807 return m
804 } else {
805 return strings.Title(method)
806 } 808 }
809 return ""
807 } else { 810 } else {
808 return strings.Title(method) 811 return strings.Title(method)
809 } 812 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!