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

checkpoint

This commit is contained in:
Lee Brown
2019-07-10 16:24:10 -08:00
parent acd1bca501
commit 4125a19156
9 changed files with 759 additions and 287 deletions

View File

@ -28,10 +28,10 @@ func (c *Check) Health(ctx context.Context, w http.ResponseWriter, r *http.Reque
}
// check redis
//err = c.Redis.Ping().Err()
//if err != nil {
// return errors.Wrap(err, "Redis failed")
//}
err = c.Redis.Ping().Err()
if err != nil {
return errors.Wrap(err, "Redis failed")
}
status := struct {
Status string `json:"status"`
@ -41,3 +41,11 @@ func (c *Check) Health(ctx context.Context, w http.ResponseWriter, r *http.Reque
return web.RespondJson(ctx, w, status, http.StatusOK)
}
// Ping validates the service is ready to accept requests.
func (c *Check) Ping(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {
status := "pong"
return web.RespondJson(ctx, w, status, http.StatusOK)
}

View File

@ -23,8 +23,10 @@ func API(shutdown chan os.Signal, log *log.Logger, masterDB *sqlx.DB, redis *red
// Register health check endpoint. This route is not authenticated.
check := Check{
MasterDB: masterDB,
Redis: redis,
}
app.Handle("GET", "/v1/health", check.Health)
app.Handle("GET", "/ping", check.Ping)
// Register user management and authentication endpoints.
u := User{