mirror of
https://github.com/yusing/godoxy.git
synced 2026-01-11 22:30:47 +01:00
- Updated health-related functions to return simplified health information. - Introduced HealthStatusString type for correct swagger and schema generation. - Refactored HealthJSON structure to utilize the new HealthStatusString type.
35 lines
897 B
Go
35 lines
897 B
Go
package v1
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/yusing/godoxy/internal/route/routes"
|
|
"github.com/yusing/goutils/http/httpheaders"
|
|
"github.com/yusing/goutils/http/websocket"
|
|
|
|
_ "github.com/yusing/goutils/apitypes"
|
|
)
|
|
|
|
// @x-id "health"
|
|
// @BasePath /api/v1
|
|
// @Summary Get routes health info
|
|
// @Description Get health info by route name
|
|
// @Tags v1,websocket
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} routes.HealthMap "Health info by route name"
|
|
// @Failure 403 {object} apitypes.ErrorResponse
|
|
// @Failure 500 {object} apitypes.ErrorResponse
|
|
// @Router /health [get]
|
|
func Health(c *gin.Context) {
|
|
if httpheaders.IsWebsocket(c.Request.Header) {
|
|
websocket.PeriodicWrite(c, 1*time.Second, func() (any, error) {
|
|
return routes.GetHealthInfoSimple(), nil
|
|
})
|
|
} else {
|
|
c.JSON(http.StatusOK, routes.GetHealthInfoSimple())
|
|
}
|
|
}
|