From 635028350ed86e2d90fea4926efd123407ceb89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 14 Sep 2021 19:37:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A7=A3=E6=9E=90get?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gin/request/util.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gin/request/util.go b/gin/request/util.go index e4be457..2a85013 100644 --- a/gin/request/util.go +++ b/gin/request/util.go @@ -57,6 +57,17 @@ func ParseGetRequestURI(url *url.URL) map[string][]string { // Author : zhangdeman001@ke.com<白茶清欢> // // Date : 9:07 下午 2021/7/24 -func ParseGetRequestBody(ctx *gin.Context) { - +func ParseGetRequestBody(ctx *gin.Context) map[string]string { + result := make(map[string]string) + urlRaw := strings.TrimLeft(ctx.Request.URL.RawQuery, "/") + queryArr := strings.Split(urlRaw, "&") + for _, itemPair := range queryArr { + itemPairArr := strings.Split(itemPair, "=") + if len(itemPairArr) == 1 { + result[itemPairArr[0]] = "" + } else { + result[itemPairArr[0]] = strings.Join(itemPairArr[1:], "=") + } + } + return result }