1
0
Fork 0
mirror of https://github.com/thomiceli/opengist.git synced 2025-01-25 15:20:36 +00:00
opengist/internal/web/healthcheck.go

32 lines
646 B
Go
Raw Normal View History

2023-12-16 01:27:00 +01:00
package web
import (
"github.com/labstack/echo/v4"
"github.com/thomiceli/opengist/internal/db"
"time"
)
func healthcheck(ctx echo.Context) error {
// Check database connection
dbOk := "ok"
httpStatus := 200
err := db.Ping()
if err != nil {
dbOk = "ko"
httpStatus = 503
}
return ctx.JSON(httpStatus, map[string]interface{}{
2024-01-04 16:45:57 +01:00
"opengist": "ok",
2023-12-16 01:27:00 +01:00
"database": dbOk,
"time": time.Now().Format(time.RFC3339),
})
}
2024-09-12 01:45:30 +02:00
// metrics is a dummy handler to satisfy the /metrics endpoint (for Prometheus, Openmetrics, etc.)
// until we have a proper metrics endpoint
func metrics(ctx echo.Context) error {
return ctx.String(200, "")
}