diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/basic-go.iml b/.idea/basic-go.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/basic-go.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5838d19 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/cmd/api/main.go b/cmd/api/main.go index 4d48f95..1d42caa 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -1,11 +1,11 @@ package main import ( - _ "test-go/docs" - "test-go/internal/api/routes" - "test-go/internal/jenkins" - "test-go/internal/logger" - "test-go/internal/middleware" + _ "basic-go/docs" + "basic-go/internal/api/routes" + "basic-go/internal/jenkins" + "basic-go/internal/logger" + "basic-go/internal/middleware" "github.com/gin-gonic/gin" ) diff --git a/docs/docs.go b/docs/docs.go index 07bd285..c88450f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -34,6 +34,21 @@ const docTemplate = `{ } } } + }, + "post": { + "description": "Health check and return app's metadata", + "produces": [ + "application/json" + ], + "summary": "Health check application", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + } } } }, diff --git a/docs/swagger.json b/docs/swagger.json index c7e6f9b..5899992 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -27,6 +27,21 @@ } } } + }, + "post": { + "description": "Health check and return app's metadata", + "produces": [ + "application/json" + ], + "summary": "Health check application", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + } } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 052d797..ed11cc4 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -19,6 +19,16 @@ paths: schema: type: string summary: Health check application + post: + description: Health check and return app's metadata + produces: + - application/json + responses: + "200": + description: OK + schema: + type: string + summary: Health check application securityDefinitions: Bearer: in: header diff --git a/go.mod b/go.mod index 6e61990..0c612f0 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module test-go +module basic-go go 1.22.6 diff --git a/internal/api/handlers/search.go b/internal/api/handlers/search.go index 57c256d..58956bf 100644 --- a/internal/api/handlers/search.go +++ b/internal/api/handlers/search.go @@ -1,12 +1,12 @@ package handlers import ( + "basic-go/internal/search" "context" "encoding/json" "fmt" "net/http" "strings" - "test-go/internal/search" "github.com/gin-gonic/gin" ) diff --git a/internal/api/handlers/telegram.go b/internal/api/handlers/telegram.go index 398b834..af8664b 100644 --- a/internal/api/handlers/telegram.go +++ b/internal/api/handlers/telegram.go @@ -1,9 +1,9 @@ package handlers import ( + "basic-go/internal/jenkins" "fmt" "net/http" - "test-go/internal/jenkins" "github.com/gin-gonic/gin" ) diff --git a/internal/api/routes/routes.go b/internal/api/routes/routes.go index 1d9f0e0..a498239 100644 --- a/internal/api/routes/routes.go +++ b/internal/api/routes/routes.go @@ -1,7 +1,7 @@ package routes import ( - "test-go/internal/controller" + "basic-go/internal/controller" "github.com/gin-gonic/gin" swaggerFiles "github.com/swaggo/files" @@ -12,6 +12,7 @@ func SetupRoutes(router *gin.Engine) { c := controller.NewController() // router.POST("/", handlers.HandleTelegramBotMessage) router.GET("/health", c.HealthCheck) + router.POST("/health", c.HealthCheck1) AddSearchRoutes(router) router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) } diff --git a/internal/api/routes/search_routes.go b/internal/api/routes/search_routes.go index ac34ac9..1f649a4 100644 --- a/internal/api/routes/search_routes.go +++ b/internal/api/routes/search_routes.go @@ -1,7 +1,7 @@ package routes import ( - "test-go/internal/api/handlers" + "basic-go/internal/api/handlers" "github.com/gin-gonic/gin" ) diff --git a/internal/controller/health.go b/internal/controller/health.go index 06ac357..4283e53 100644 --- a/internal/controller/health.go +++ b/internal/controller/health.go @@ -24,3 +24,16 @@ func (c *Controller) HealthCheck(ctx *gin.Context) { "buildTime": BuildTime, }) } + +// @Summary Health check application +// @Description Health check and return app's metadata +// @Produce json +// @Success 200 {object} string +// @Router /health [post] +func (c *Controller) HealthCheck1(ctx *gin.Context) { + ctx.JSON(http.StatusOK, gin.H{ + "version": Version, + "commit": Commit, + "buildTime": BuildTime, + }) +}