From 90b013698b92199196713e2e90c75ec08863d7cc Mon Sep 17 00:00:00 2001 From: JurajKubrican Date: Mon, 4 Aug 2025 22:14:56 +0200 Subject: [PATCH] improved healthcheck --- src/main.go | 6 +++++- src/util/util.go | 6 ------ views/health.html | 3 +++ 3 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 views/health.html diff --git a/src/main.go b/src/main.go index 34462f7..28a320b 100644 --- a/src/main.go +++ b/src/main.go @@ -55,7 +55,11 @@ func main() { e.Use(middleware.HTTPSRedirect()) } - e.GET("/health", util.HealthCheck) + e.GET("/health", func(c echo.Context) error { + return c.Render(200, "health", Page{ + BuildNumber: util.GetBuildNumber(), + }) + }) e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { diff --git a/src/util/util.go b/src/util/util.go index 9c3e851..ded0923 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -2,8 +2,6 @@ package util import ( "os" - - "github.com/labstack/echo/v4" ) func GetBuildNumber() string { @@ -13,7 +11,3 @@ func GetBuildNumber() string { func IsProd() bool { return len(GetBuildNumber()) > 0 } - -func HealthCheck(c echo.Context) error { - return c.String(200, "OK") -} diff --git a/views/health.html b/views/health.html new file mode 100644 index 0000000..3c0b39a --- /dev/null +++ b/views/health.html @@ -0,0 +1,3 @@ +{{block "health" .}} +OK {{ .BuildNumber }} +{{end}}