mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-12 19:01:50 +02:00
Refactor server code (#407)
This commit is contained in:
25
internal/web/handlers/health/healthcheck.go
Normal file
25
internal/web/handlers/health/healthcheck.go
Normal file
@ -0,0 +1,25 @@
|
||||
package health
|
||||
|
||||
import (
|
||||
"github.com/thomiceli/opengist/internal/db"
|
||||
"github.com/thomiceli/opengist/internal/web/context"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Healthcheck(ctx *context.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{}{
|
||||
"opengist": "ok",
|
||||
"database": dbOk,
|
||||
"time": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user