Skip logging of health check requests

This commit is contained in:
PB
2022-12-02 21:51:51 +01:00
parent 6f7fdad944
commit ec4164a9e2
2 changed files with 8 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
package server
import (
"strings"
"git.pbiernat.dev/egommerce/go-api-pkg/fluentd"
"github.com/gofiber/fiber/v2"
)
@@ -20,6 +22,11 @@ func SetupMiddlewares(s *Server) {
// Middlewares
func LoggingMiddleware(log *fluentd.Logger) func(c *fiber.Ctx) error {
return func(c *fiber.Ctx) error {
path := string(c.Request().URI().Path())
if strings.Contains(path, "/health") {
return c.Next()
}
log.Log("Request: %s, remote: %s, via: %s",
c.Request().URI().String(),
c.Context().RemoteIP().String(),