forked from mirror/gin
Error middleware does not write if the it is already written
This commit is contained in:
parent
598c78297c
commit
dcdf7b92f4
|
@ -29,13 +29,14 @@ func ErrorLoggerT(typ uint32) HandlerFunc {
|
|||
return func(c *Context) {
|
||||
c.Next()
|
||||
|
||||
if !c.Writer.Written() {
|
||||
errs := c.Errors.ByType(typ)
|
||||
if len(errs) > 0 {
|
||||
// -1 status code = do not change current one
|
||||
c.JSON(-1, c.Errors)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Logger() HandlerFunc {
|
||||
return LoggerInFile(DefaultLogFile)
|
||||
|
|
Loading…
Reference in New Issue