From fd3c8834da91278ec44441895ce5923067bfab9e Mon Sep 17 00:00:00 2001 From: astaxie Date: Sun, 4 Aug 2013 23:13:29 +0800 Subject: [PATCH] autorouter when /admin 301 to /admin/ --- router.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/router.go b/router.go index 0de16cc1..67690a8a 100644 --- a/router.go +++ b/router.go @@ -544,6 +544,12 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) if !findrouter { for cName, methodmap := range p.autoRouter { + + if strings.ToLower(requestPath) == "/"+cName { + http.Redirect(w, r, requestPath+"/", 301) + return + } + if strings.ToLower(requestPath) == "/"+cName+"/" { requestPath = requestPath + "index" }