health.go 798 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package health
  2. import (
  3. "net/http"
  4. "github.com/gin-gonic/gin"
  5. "github.com/metarare/metarare_api/common"
  6. "gorm.io/gorm"
  7. )
  8. type HealthV1Router struct {
  9. group *gin.RouterGroup
  10. mDB *gorm.DB
  11. rDB *gorm.DB
  12. }
  13. func NewHealthV1Router(r common.Router, basePath string) HealthV1Router {
  14. h := HealthV1Router{
  15. group: r.Version.Group(basePath),
  16. mDB: r.Db.MasterDB,
  17. rDB: r.Db.ReadDB,
  18. }
  19. h.group.GET("health", h.healthCheck)
  20. return h
  21. }
  22. // healthCheck godoc
  23. // @Summary API to check the status of the server
  24. // @Schemes
  25. // @Description API to check the status of the server
  26. // @Tags health check
  27. // @Accept json
  28. // @Produce json
  29. // @Success 200 {string} status OK!!
  30. // @Router /health [get]
  31. func (h HealthV1Router) healthCheck(c *gin.Context) {
  32. c.JSON(http.StatusOK, "healthy!!")
  33. }