未验证 提交 b2796ad0 编写于 作者: L lvshaoyuan 提交者: GitHub

email.go:再重新写回请求体body中,ioutil.ReadAll会清空c.Request.Body中的数据 (#1027)

Co-authored-by: Noldlv <15237336850@163.com>
上级 4a927920
package middleware package middleware
import ( import (
"bytes"
"io/ioutil" "io/ioutil"
"strconv" "strconv"
"time" "time"
...@@ -32,6 +33,8 @@ func ErrorToEmail() gin.HandlerFunc { ...@@ -32,6 +33,8 @@ func ErrorToEmail() gin.HandlerFunc {
username = user.Username username = user.Username
} }
body, _ := ioutil.ReadAll(c.Request.Body) body, _ := ioutil.ReadAll(c.Request.Body)
// 再重新写回请求体body中,ioutil.ReadAll会清空c.Request.Body中的数据
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body))
record := system.SysOperationRecord{ record := system.SysOperationRecord{
Ip: c.ClientIP(), Ip: c.ClientIP(),
Method: c.Request.Method, Method: c.Request.Method,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册