gin-nice-recovery
gin-nice-recovery copied to clipboard
Does not work when also using gzip middleware
When running along with gzip provided by https://github.com/gin-contrib/gzip the page does not render HTML and instead downloads a "download.gz" file in chrome/firefox.
c.Use(nice.Recovery(recoveryHandler))
c.Use(gzip.Gzip(gzip.DefaultCompression))
func recoveryHandler(c *gin.Context, err interface{}) {
errorPage(c, http.StatusInternalServerError, "Internal Server Error", "Our apologies there seems to have been a unhanded error.")
return
}
func errorPage(c *gin.Context, errCode int, errCodeTxt string, errTxt string) {
c.HTML(http.StatusNotFound, "errors.html", gin.H{
"error_code": errCode,
"error_code_test": errCodeTxt,
"error_text": errTxt,
})
}```
Try this:
c.Use(gzip.Gzip(gzip.DefaultCompression))
c.Use(nice.Recovery(recoveryHandler))