From 53c5d8f1c6b2180816da99090b001ec187ba952a Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Thu, 8 Jun 2023 21:06:04 -0400 Subject: [PATCH] [BREAKING] Ajouter response.Data pour GetHealth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implémenter GetHealthResponse et GetHealthResponseData --- handlers/health.go | 15 ++++++++++----- responses/responses.go | 10 ++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) 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"` }