From ec4164a9e22f7abae237751a7915587f742cb5bb Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Fri, 2 Dec 2022 21:51:51 +0100 Subject: [PATCH] Skip logging of health check requests --- Dockerfile.target | 2 +- src/internal/app/server/router.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile.target b/Dockerfile.target index 3ad6fa6..8047221 100644 --- a/Dockerfile.target +++ b/Dockerfile.target @@ -11,7 +11,7 @@ ARG SVC_NAME ARG SVC_VER LABEL dev.egommerce.image.author="Piotr Biernat" -LABEL dev.egommerce.image.service="identity-svc" +LABEL dev.egommerce.image.vendor="Egommerce" LABEL dev.egommerce.image.service=${SVC_NAME} LABEL dev.egommerce.image.version=${SVC_VER} diff --git a/src/internal/app/server/router.go b/src/internal/app/server/router.go index 6aaf4cd..8d34acc 100644 --- a/src/internal/app/server/router.go +++ b/src/internal/app/server/router.go @@ -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(),