mirror of https://github.com/gin-gonic/gin.git
We do not longer have to call JSON() explicitly
This commit is contained in:
parent
352868ef90
commit
d6425f1692
|
@ -28,11 +28,11 @@ func ErrorLogger() HandlerFunc {
|
||||||
func ErrorLoggerT(typ ErrorType) HandlerFunc {
|
func ErrorLoggerT(typ ErrorType) HandlerFunc {
|
||||||
return func(c *Context) {
|
return func(c *Context) {
|
||||||
c.Next()
|
c.Next()
|
||||||
|
// avoid writting if we already wrote into the response body
|
||||||
if !c.Writer.Written() {
|
if !c.Writer.Written() {
|
||||||
json := c.Errors.ByType(typ).JSON()
|
errors := c.Errors.ByType(typ)
|
||||||
if json != nil {
|
if len(errors) > 0 {
|
||||||
c.JSON(-1, json)
|
c.JSON(-1, errors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue