diff --git a/manager/middleware.go b/manager/middleware.go new file mode 100644 index 0000000..df00426 --- /dev/null +++ b/manager/middleware.go @@ -0,0 +1,16 @@ +package manager + +import ( + "github.com/gin-gonic/gin" +) + +func contextErrorLogger(c *gin.Context) { + errs := c.Errors.ByType(gin.ErrorTypeAny) + if len(errs) > 0 { + for _, err := range errs { + logger.Error(`"in request "%s %s: %s"`, c.Request.Method, c.Request.URL.Path, err.Error()) + } + } + // pass on to the next middleware in chain + c.Next() +}