Error middleware does not write if the it is already written

This commit is contained in:
Manu Mtz-Almeida 2015-04-07 18:52:33 +02:00
parent 598c78297c
commit dcdf7b92f4
1 changed files with 5 additions and 4 deletions

View File

@ -29,13 +29,14 @@ func ErrorLoggerT(typ uint32) HandlerFunc {
return func(c *Context) { return func(c *Context) {
c.Next() c.Next()
if !c.Writer.Written() {
errs := c.Errors.ByType(typ) errs := c.Errors.ByType(typ)
if len(errs) > 0 { if len(errs) > 0 {
// -1 status code = do not change current one
c.JSON(-1, c.Errors) c.JSON(-1, c.Errors)
} }
} }
} }
}
func Logger() HandlerFunc { func Logger() HandlerFunc {
return LoggerInFile(DefaultLogFile) return LoggerInFile(DefaultLogFile)