恐慌后在杜松子酒中获取有效载荷

How can I get all the data sent to the server after panic() to be dumped into log.Printf() using Gin?

I'm making a small change where after a panic, we want to collect all the data that was sent.

I've been using this (https://github.com/gin-gonic/gin#custom-log-format), but haven't found a way for it to detect panics or collect data dumps, the body is always empty.

r.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
    var bodyBytes []byte
    if param.Request.Body != nil {
        bodyBytes, _ = ioutil.ReadAll(param.Request.Body)
    }

    param.Request.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))

    // This is always empty :(
    payloadString := string(bodyBytes)
}))

I have also copied Gin's function and modified it, but r.Use(gin.Recovery()) but still no success.

Thanks in advance!