From 098d255190fc5c441269288afe3efe145f80d9df Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 2 Jun 2023 02:35:15 -0400 Subject: [PATCH] =?UTF-8?q?D=C3=A9placer=20/v4=20->=20/v4/health?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renommer handler GetV4 pour GetHealth Ajouter GetHealthResponse pour serialize et deserialize json response --- cmd/api.go | 2 +- handlers/health.go | 17 +++++++++++++++++ handlers/v4.go | 13 ------------- 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 handlers/health.go delete mode 100644 handlers/v4.go diff --git a/cmd/api.go b/cmd/api.go index e44632c..a948b78 100644 --- a/cmd/api.go +++ b/cmd/api.go @@ -49,7 +49,7 @@ var apiCmd = &cobra.Command{ // Routes - e.GET("/v4/", handlers.GetV4) + e.GET("/v4/health", handlers.GetHealth) e.POST("/v4/membres/", handlers.PostMembres) diff --git a/handlers/health.go b/handlers/health.go new file mode 100644 index 0000000..d917738 --- /dev/null +++ b/handlers/health.go @@ -0,0 +1,17 @@ +package handlers + +import ( + "net/http" + + "github.com/labstack/echo/v4" +) + +type GetHealthResponse struct { + Message string `json:"message"` +} + +func GetHealth(c echo.Context) error { + response := GetHealthResponse{"Bottin API v4 is ready"} + + return c.JSON(http.StatusOK, response) +} diff --git a/handlers/v4.go b/handlers/v4.go deleted file mode 100644 index facbdde..0000000 --- a/handlers/v4.go +++ /dev/null @@ -1,13 +0,0 @@ -package handlers - -import ( - "net/http" - - "github.com/labstack/echo/v4" -) - -func GetV4(c echo.Context) error { - return c.JSON(http.StatusOK, map[string]string{ - "message": "Bottin API v4 is ready", - }) -}