From 4b3ed531581673717a9cfefadae3fd68ba7b6cd9 Mon Sep 17 00:00:00 2001 From: Maxgis Date: Tue, 26 Jul 2016 19:54:10 +0800 Subject: [PATCH] redirect should add query params --- staticfile.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/staticfile.go b/staticfile.go index 11a2cdcc..7c8b4517 100644 --- a/staticfile.go +++ b/staticfile.go @@ -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)