12345678910111213141516171819202122 |
- package frame
- import (
- "bytes"
- "github.com/gin-gonic/gin"
- )
- type BodyLogWriter struct {
- gin.ResponseWriter
- Body *bytes.Buffer
- }
- func (w BodyLogWriter) Write(b []byte) (int, error) {
- w.Body.Write(b)
- return w.ResponseWriter.Write(b)
- }
- func BodyMiddleware(c *Context) {
- blw := &BodyLogWriter{Body: bytes.NewBufferString(""), ResponseWriter: c.Writer}
- c.Writer = blw
- c.Next()
- }
|