improved healthcheck

This commit is contained in:
JurajKubrican
2025-08-04 22:14:56 +02:00
parent 17bd68b797
commit 90b013698b
3 changed files with 8 additions and 7 deletions

View File

@@ -55,7 +55,11 @@ func main() {
e.Use(middleware.HTTPSRedirect()) 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 { e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error { return func(c echo.Context) error {

View File

@@ -2,8 +2,6 @@ package util
import ( import (
"os" "os"
"github.com/labstack/echo/v4"
) )
func GetBuildNumber() string { func GetBuildNumber() string {
@@ -13,7 +11,3 @@ func GetBuildNumber() string {
func IsProd() bool { func IsProd() bool {
return len(GetBuildNumber()) > 0 return len(GetBuildNumber()) > 0
} }
func HealthCheck(c echo.Context) error {
return c.String(200, "OK")
}

3
views/health.html Normal file
View File

@@ -0,0 +1,3 @@
{{block "health" .}}
OK {{ .BuildNumber }}
{{end}}