improved healthcheck
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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
3
views/health.html
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{{block "health" .}}
|
||||||
|
OK {{ .BuildNumber }}
|
||||||
|
{{end}}
|
||||||
Reference in New Issue
Block a user