1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 13:00:54 +00:00

Merge pull request #2064 from Maxgis/feature_static

redirect path should add  query params
This commit is contained in:
astaxie 2016-07-27 12:55:21 +08:00 committed by GitHub
commit d08e3d1b11

View File

@ -57,7 +57,11 @@ func serverStaticRouter(ctx *context.Context) {
if fileInfo.IsDir() {
requestURL := ctx.Input.URL()
if requestURL[len(requestURL)-1] != '/' {
ctx.Redirect(302, requestURL+"/")
redirectURL := requestURL + "/"
if ctx.Request.URL.RawQuery != "" {
redirectURL = redirectURL + "?" + ctx.Request.URL.RawQuery
}
ctx.Redirect(302, redirectURL)
} else {
//serveFile will list dir
http.ServeFile(ctx.ResponseWriter, ctx.Request, filePath)