middleware.go 348 B

12345678910111213141516
  1. package manager
  2. import (
  3. "github.com/gin-gonic/gin"
  4. )
  5. func contextErrorLogger(c *gin.Context) {
  6. errs := c.Errors.ByType(gin.ErrorTypeAny)
  7. if len(errs) > 0 {
  8. for _, err := range errs {
  9. logger.Error(`"in request "%s %s: %s"`, c.Request.Method, c.Request.URL.Path, err.Error())
  10. }
  11. }
  12. // pass on to the next middleware in chain
  13. c.Next()
  14. }