diff --git a/handlers/health.go b/handlers/health.go index 47d8177..f193544 100644 --- a/handlers/health.go +++ b/handlers/health.go @@ -4,12 +4,16 @@ import ( "net/http" "git.agecem.com/agecem/bottin-agenda/data" + "git.agecem.com/agecem/bottin-agenda/responses" bottindata "git.agecem.com/agecem/bottin/v5/data" "github.com/labstack/echo/v4" "github.com/spf13/viper" ) func GetHealth(c echo.Context) error { + var response responses.GetHealthResponse + var statusCode int = http.StatusNotImplemented + bottinApiKey := viper.GetString("bottin.api.key") bottinApiHost := viper.GetString("bottin.api.host") bottinApiProtocol := viper.GetString("bottin.api.protocol") @@ -48,9 +52,10 @@ func GetHealth(c echo.Context) error { } } - return c.JSON(http.StatusOK, map[string]string{ - "message": "Bottin-agenda API v2 is ready", - "bottin": bottinStatus, - "database": databaseStatus, - }) + statusCode = http.StatusOK + response.Message = "Bottin-agenda API v3 is ready" + response.Data.Bottin = bottinStatus + response.Data.Database = databaseStatus + + return c.JSON(statusCode, response) } diff --git a/responses/responses.go b/responses/responses.go index 7ac2507..e54f155 100644 --- a/responses/responses.go +++ b/responses/responses.go @@ -4,6 +4,16 @@ import ( "git.agecem.com/agecem/bottin-agenda/models" ) +type GetHealthResponseData struct { + Bottin string `json:"bottin"` + Database string `json:"database"` +} + +type GetHealthResponse struct { + Message string `json:"message"` + Data GetHealthResponseData `json:"data"` +} + type PostSeedResponse struct { Message string `json:"message"` }