mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-23 13:02:39 +00:00
25 lines
414 B
Go
25 lines
414 B
Go
|
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{}{
|
||
|
"database": dbOk,
|
||
|
"time": time.Now().Format(time.RFC3339),
|
||
|
})
|
||
|
}
|