[#1233] added health API endpoint

This commit is contained in:
Marvin Wendt
2022-12-11 16:27:46 +01:00
committed by GitHub
parent 506bfca8b2
commit 5c899a4cf0
3 changed files with 54 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
package apis
import (
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase/core"
"net/http"
)
// 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.",
}
return c.JSON(http.StatusOK, payload)
}