disable fiber startup message in production
Alan Pearce alan@alanpearce.eu
Thu, 18 Apr 2024 17:25:56 +0200
2 files changed, 6 insertions(+), 2 deletions(-)
M internal/config/config.go → internal/config/config.go
@@ -36,6 +36,7 @@ DefaultLanguage string `toml:"default_language"` BaseURL URL `toml:"base_url"` RedirectOtherHostnames bool `toml:"redirect_other_hostnames"` Port uint64 + Production bool Title string Email string Description string @@ -85,7 +86,8 @@ if err != nil { return nil, err } config.Port = port - if os.Getenv("ENV") != "production" { + config.Production = os.Getenv("ENV") == "production" + if !config.Production { err = setDevelopmentOverrides(&config) if err != nil { return nil, errors.WithMessage(err, "could not override configuration")
M server.go → server.go
@@ -117,7 +117,9 @@ })) website.Use(notFoundHandler) hosts[config.BaseURL.Host] = &Host{website} - toplevel := fiber.New() + toplevel := fiber.New(fiber.Config{ + DisableStartupMessage: config.Production, + }) toplevel.Get("/health", func(c *fiber.Ctx) error { return c.SendStatus(fiber.StatusOK) })