1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-06-06 23:46:29 +02:00

33 lines
707 B
Go
Raw Normal View History

package handlers
import (
"context"
"net/http"
"geeks-accelerator/oss/saas-starter-kit/example-project/internal/platform/web"
2019-05-23 14:32:24 -05:00
"github.com/jmoiron/sqlx"
)
// Check provides support for orchestration health checks.
type Check struct {
2019-05-23 14:32:24 -05:00
MasterDB *sqlx.DB
// ADD OTHER STATE LIKE THE LOGGER IF NEEDED.
}
// Health validates the service is healthy and ready to accept requests.
func (c *Check) Health(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {
2019-05-23 14:32:24 -05:00
_, err := c.MasterDB.Exec("SELECT 1")
if err != nil {
return err
}
status := struct {
Status string `json:"status"`
}{
Status: "ok",
}
2019-05-23 14:32:24 -05:00
return web.RespondJson(ctx, w, status, http.StatusOK)
}