Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Quang nd committed Sep 27, 2024
1 parent bc56dd5 commit a3463aa
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/basic-go.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down
15 changes: 15 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
}
},
Expand Down
15 changes: 15 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
}
},
Expand Down
10 changes: 10 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module test-go
module basic-go

go 1.22.6

Expand Down
2 changes: 1 addition & 1 deletion internal/api/handlers/search.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/api/handlers/telegram.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package handlers

import (
"basic-go/internal/jenkins"
"fmt"
"net/http"
"test-go/internal/jenkins"

"github.com/gin-gonic/gin"
)
Expand Down
3 changes: 2 additions & 1 deletion internal/api/routes/routes.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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))
}
2 changes: 1 addition & 1 deletion internal/api/routes/search_routes.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package routes

import (
"test-go/internal/api/handlers"
"basic-go/internal/api/handlers"

"github.com/gin-gonic/gin"
)
Expand Down
13 changes: 13 additions & 0 deletions internal/controller/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

0 comments on commit a3463aa

Please sign in to comment.