all repos — website @ 477c7bf60099cf33984894744846a278fc884786

My website

disable logging of healthcheck requests
Alan Pearce alan@alanpearce.eu
Thu, 18 Apr 2024 17:24:41 +0200
commit

477c7bf60099cf33984894744846a278fc884786

parent

320d0cbf276a89ac38e3b90b8cfc129a721adf95

1 files changed, 4 insertions(+), 1 deletions(-)

jump to
M server.goserver.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()]