Open
Description
If set the handler time.Sleep same as the timeout, there is a chance to reproduce this error!
api.GET("/test", timeout.New(
timeout.WithTimeout(200*time.Microsecond),
timeout.WithHandler(func(c *gin.Context) {
time.Sleep(200*time.Microsecond)
c.JSON(http.StatusOK, gin.H{
"code": 200,
"data": "",
})
}),
timeout.WithResponse(func(c *gin.Context) {
c.JSON(http.StatusRequestTimeout, gin.H{
"code": "408",
"message": "test",
})
}),
))
Here is gin panic code line:
https://github.com/gin-gonic/gin/blob/580e7da6eed01e2926de1240ec31f6473cd1a2af/render/render.go#L38
There is also a chance of combined http results:
{
"code": 200,
"data": ""
}{
"code": "408",
"message": "test"
}
I can't think of a solution at the moment, does anyone have any good ideas?