2022-12-11 17:27:46 +02:00
|
|
|
package apis
|
|
|
|
|
|
|
|
import (
|
2022-12-11 17:32:43 +02:00
|
|
|
"net/http"
|
|
|
|
|
2022-12-11 17:27:46 +02:00
|
|
|
"github.com/labstack/echo/v5"
|
|
|
|
"github.com/pocketbase/pocketbase/core"
|
|
|
|
)
|
|
|
|
|
|
|
|
// bindHealthApi registers the health api endpoint.
|
|
|
|
func bindHealthApi(app core.App, rg *echo.Group) {
|
|
|
|
api := healthApi{app: app}
|
|
|
|
|
|
|
|
subGroup := rg.Group("/health")
|
|
|
|
subGroup.GET("", api.healthCheck)
|
|
|
|
}
|
|
|
|
|
|
|
|
type healthApi struct {
|
|
|
|
app core.App
|
|
|
|
}
|
|
|
|
|
|
|
|
// healthCheck returns a 200 OK response if the server is healthy.
|
|
|
|
func (api *healthApi) healthCheck(c echo.Context) error {
|
|
|
|
payload := map[string]any{
|
|
|
|
"code": http.StatusOK,
|
|
|
|
"message": "API is healthy.",
|
|
|
|
}
|
2022-12-11 17:32:43 +02:00
|
|
|
|
2022-12-11 17:27:46 +02:00
|
|
|
return c.JSON(http.StatusOK, payload)
|
|
|
|
}
|