Skip to content

Commit b2796ad

Browse files
authored
email.go:再重新写回请求体body中,ioutil.ReadAll会清空c.Request.Body中的数据 (#1027)
Co-authored-by: oldlv <15237336850@163.com>
1 parent 4a92792 commit b2796ad

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

server/middleware/email.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package middleware
22

33
import (
4+
"bytes"
45
"io/ioutil"
56
"strconv"
67
"time"
@@ -32,6 +33,8 @@ func ErrorToEmail() gin.HandlerFunc {
3233
username = user.Username
3334
}
3435
body, _ := ioutil.ReadAll(c.Request.Body)
36+
// 再重新写回请求体body中,ioutil.ReadAll会清空c.Request.Body中的数据
37+
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body))
3538
record := system.SysOperationRecord{
3639
Ip: c.ClientIP(),
3740
Method: c.Request.Method,

0 commit comments

Comments
 (0)