🐛 Only send response if not already sent

This commit is contained in:
Dan Jones 2024-02-07 08:49:09 -06:00
commit 119d73aae1

View file

@ -55,7 +55,8 @@ func ErrorMiddleware(opts ...Option) gin.HandlerFunc {
c.Set("rendered_error", re)
// @todo check a response hasn't already been sent
c.JSON(re.Status(), re)
if !c.Writer.Written() {
c.JSON(re.Status(), re)
}
}
}