From dcdf7b92f457b27459a8a58e3e5a9770b02a9ad9 Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Tue, 7 Apr 2015 18:52:33 +0200 Subject: [PATCH] Error middleware does not write if the it is already written --- logger.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/logger.go b/logger.go index 4418ef89..0e02600d 100644 --- a/logger.go +++ b/logger.go @@ -29,10 +29,11 @@ func ErrorLoggerT(typ uint32) HandlerFunc { return func(c *Context) { c.Next() - errs := c.Errors.ByType(typ) - if len(errs) > 0 { - // -1 status code = do not change current one - c.JSON(-1, c.Errors) + if !c.Writer.Written() { + errs := c.Errors.ByType(typ) + if len(errs) > 0 { + c.JSON(-1, c.Errors) + } } } }