mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:50:55 +00:00
redirect should add query params
This commit is contained in:
parent
e951c555e4
commit
4b3ed53158
@ -57,7 +57,11 @@ func serverStaticRouter(ctx *context.Context) {
|
|||||||
if fileInfo.IsDir() {
|
if fileInfo.IsDir() {
|
||||||
requestURL := ctx.Input.URL()
|
requestURL := ctx.Input.URL()
|
||||||
if requestURL[len(requestURL)-1] != '/' {
|
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 {
|
} else {
|
||||||
//serveFile will list dir
|
//serveFile will list dir
|
||||||
http.ServeFile(ctx.ResponseWriter, ctx.Request, filePath)
|
http.ServeFile(ctx.ResponseWriter, ctx.Request, filePath)
|
||||||
|
Loading…
Reference in New Issue
Block a user