From f2119e38c457cb4643e5286867e8b81dd4caebfd Mon Sep 17 00:00:00 2001 From: jannikf02 Date: Mon, 12 Aug 2024 21:00:26 +0000 Subject: [PATCH] Adds health endpoint --- backend/aashub/cmd/aashub/main.go | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/backend/aashub/cmd/aashub/main.go b/backend/aashub/cmd/aashub/main.go index 906ab6b..b694e25 100644 --- a/backend/aashub/cmd/aashub/main.go +++ b/backend/aashub/cmd/aashub/main.go @@ -18,17 +18,15 @@ import ( // @BasePath /api/v1 -// PingExample godoc -// @Summary ping example -// @Schemes -// @Description do ping -// @Tags example -// @Accept json -// @Produce json -// @Success 200 {string} Helloworld -// @Router /example/helloworld [get] -func Helloworld(g *gin.Context) { - g.JSON(http.StatusOK, "helloworld") +// Health godoc +// @Summary Health Check +// @Description Responds with OK if the service is up and running +// @Tags health +// @Produce plain +// @Success 200 {string} string "OK" +// @Router /health [get] +func Health(g *gin.Context) { + g.JSON(http.StatusOK, "OK") } func main() { @@ -63,10 +61,6 @@ func main() { docs.SwaggerInfo.BasePath = "/api/v1" v1 := r.Group("/api/v1") { - eg := v1.Group("/example") - { - eg.GET("/helloworld", Helloworld) - } ug := v1.Group("/users") { ug.POST("/register", gin.WrapF(userHandler.RegisterUser)) @@ -78,5 +72,6 @@ func main() { } } r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) + r.GET("/health", Health) r.Run(":9000") }