disable logging of healthcheck requests
Alan Pearce alan@alanpearce.eu
Thu, 18 Apr 2024 17:24:41 +0200
1 files changed, 4 insertions(+), 1 deletions(-)
jump to
M server.go → server.go
@@ -20,6 +20,7 @@ "github.com/gofiber/fiber/v2/middleware/filesystem" "github.com/gofiber/fiber/v2/middleware/healthcheck" "github.com/gofiber/fiber/v2/middleware/logger" "github.com/gofiber/fiber/v2/middleware/recover" + "github.com/gofiber/fiber/v2/middleware/skip" "github.com/shengyanli1982/law" ) @@ -120,9 +121,11 @@ toplevel := fiber.New() toplevel.Get("/health", func(c *fiber.Ctx) error { return c.SendStatus(fiber.StatusOK) }) - toplevel.Use(logger.New(logger.Config{ + toplevel.Use(skip.New(logger.New(logger.Config{ Output: law.NewWriteAsyncer(os.Stdout, nil), Format: "${protocol} ${method} ${status} ${host} ${url} ${respHeader:Location}\n", + }), func(c *fiber.Ctx) bool { + return c.Hostname() != "fly-internal" })) toplevel.Use(func(c *fiber.Ctx) error { host := hosts[c.Hostname()]