From 0b7df330f7c080762782a99ec68eac1ef57da289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 22 Jul 2024 10:30:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=BC=83=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- request/form.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/request/form.go b/request/form.go index 7306c04..030d15e 100644 --- a/request/form.go +++ b/request/form.go @@ -10,7 +10,7 @@ package request import ( "bytes" "errors" - "io/ioutil" + "io" "net/http" "strings" @@ -37,11 +37,11 @@ type form struct { // Date : 00:34 2022/7/3 func (f *form) Parse(ctx *gin.Context, receiver interface{}) error { - requestBody, _ := ioutil.ReadAll(ctx.Request.Body) + requestBody, _ := io.ReadAll(ctx.Request.Body) // 请求信息写入上下文 ctx.Set(define.RecordRequestDataField, string(requestBody)) // 因为请求体被读一遍之后就没了,重新赋值 requestBody - ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(requestBody)) + ctx.Request.Body = io.NopCloser(bytes.NewReader(requestBody)) method := strings.ToUpper(ctx.Request.Method) if method == http.MethodGet || method == http.MethodPatch ||