gin-nice-recovery icon indicating copy to clipboard operation
gin-nice-recovery copied to clipboard

Does not work when also using gzip middleware

Open andysnowden opened this issue 6 years ago • 1 comments

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,
	})
}```

andysnowden avatar Jun 08 '19 01:06 andysnowden

Try this:

c.Use(gzip.Gzip(gzip.DefaultCompression))
c.Use(nice.Recovery(recoveryHandler))

hmldd avatar Mar 10 '20 05:03 hmldd