Files
crawlab/core/controllers/health.go
Marvin Zhang 43d1c7692b refactor: standardize response types across controllers
- Updated multiple controller methods to return VoidResponse instead of generic Response[any].
- Consolidated error handling to utilize GetErrorVoidResponse for consistent error responses.
- Enhanced parameter handling in export and file management functions for improved clarity and maintainability.
- Refactored health check and login/logout methods to align with new response structure.
- Improved overall consistency in response formatting across various endpoints.
2025-03-16 22:25:13 +08:00

18 lines
364 B
Go

package controllers
import (
"github.com/gin-gonic/gin"
"net/http"
)
func GetHealthFn(healthFn func() bool) func(c *gin.Context) {
return func(c *gin.Context) {
if healthFn() {
_, _ = c.Writer.Write([]byte("ok"))
c.AbortWithStatus(http.StatusOK)
}
_, _ = c.Writer.Write([]byte("not ready"))
c.AbortWithStatus(http.StatusServiceUnavailable)
}
}