init
This commit is contained in:
27
internal/health/handler.go
Normal file
27
internal/health/handler.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package health
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @openapi:path
|
||||
// /_health:
|
||||
//
|
||||
// get:
|
||||
// tags:
|
||||
// - "Monitoring"
|
||||
// summary: Health check
|
||||
// description: Health check
|
||||
// responses:
|
||||
// 200:
|
||||
// description: "Health response"
|
||||
// content:
|
||||
// application/json:
|
||||
// schema:
|
||||
// $ref: "#/components/schemas/Health"
|
||||
func GetHealth(c *gin.Context) {
|
||||
health := &Health{Alive: true}
|
||||
c.JSON(http.StatusOK, health)
|
||||
}
|
||||
8
internal/health/model.go
Normal file
8
internal/health/model.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package health
|
||||
|
||||
// Health struct
|
||||
// @openapi:schema
|
||||
type Health struct {
|
||||
Alive bool `json:"alive"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
15
internal/health/setup.go
Normal file
15
internal/health/setup.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package health
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/kratisto/mam-contract/internal/ginserver"
|
||||
"github.com/kratisto/mam-contract/internal/utils"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func Setup(injector *utils.Injector) {
|
||||
publicRoute := utils.Get[*gin.RouterGroup](injector, ginserver.UnsecuredRouterInjectorKey)
|
||||
//TODO add secure auth
|
||||
publicRoute.Handle(http.MethodGet, "/health", GetHealth)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user