fix the static file dir

This commit is contained in:
astaxie 2014-09-23 00:03:47 +08:00
parent 727d2f9ea1
commit 7e060e6e5c
1 changed files with 3 additions and 0 deletions

View File

@ -68,6 +68,9 @@ func serverStaticRouter(ctx *context.Context) {
if finfo.IsDir() && !DirectoryIndex {
middleware.Exception("403", ctx.ResponseWriter, ctx.Request, "403 Forbidden")
return
} else if ctx.Input.Request.URL.Path[len(ctx.Input.Request.URL.Path)-1] != '/' {
http.Redirect(ctx.ResponseWriter, ctx.Request, ctx.Input.Request.URL.Path+"/", 302)
return
}
//This block obtained from (https://github.com/smithfox/beego) - it should probably get merged into astaxie/beego after a pull request