切换弃用的函数

This commit is contained in:
白茶清欢 2024-07-22 10:30:18 +08:00
parent 8a6182d0de
commit 0b7df330f7
1 changed files with 3 additions and 3 deletions

View File

@ -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 ||