Open segevfiner opened 5 years ago
I think the cause is: https://github.com/gin-contrib/gzip/blob/aef065fb847d00a98c42db4173b7cba138112c9c/gzip.go#L44-L47 which happens before the Recovery
middleware handles the panic and sets the status code, but I'm unsure on how to fix this.
@segevfiner Try to move r.Use(gin.Recovery())
next to r.Use(gzip.Gzip(gzip.DefaultCompression))
.
package main
import (
"github.com/gin-contrib/gzip"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.New()
r.Use(gzip.Gzip(gzip.DefaultCompression))
r.Use(gin.Recovery())
r.Use(gin.Logger())
r.GET("/", func(c *gin.Context) {
panic("panic")
})
r.Run()
}
i ran into this too. a config setting or some official documentation around this would be very helpful
Build:
Run:
You get the following warning from Gin: