How to log response body in gin
<p>I need to log the response body in a middleware of gin, but I don't find how to get the response body. Can anyone help?</p>

<p>I am using a middleware like this:</p>

<pre><code>func Logger() gin.HandlerFunc {

    return func(c *gin.Context) {

        c.Next()

        statusCode := c.Writer.Status()
        if statusCode &gt;= 400 {
            //ok this is an request with error, let's make a record for it
            //log body here
        }
    }
}
</code></pre>

<p>My question is, how to get response body from Context in middleware?</p>