mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-27 17:50:53 +01:00
- Updated GetHealthFn to return an error for better error handling and clarity. - Introduced a new test file for schedule management, covering various endpoints including creation, retrieval, updating, and deletion of schedules. - Added tests for task management, including task creation, retrieval, updating, and cancellation. - Implemented utility tests for filtering and response generation to ensure consistent API behavior. - Improved logging in the task scheduler service for better traceability.
21 lines
421 B
Go
21 lines
421 B
Go
package controllers
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
)
|
|
|
|
func GetHealthFn(healthFn func() bool) func(c *gin.Context) error {
|
|
return func(c *gin.Context) (err error) {
|
|
if healthFn() {
|
|
c.Writer.Write([]byte("ok"))
|
|
c.AbortWithStatus(http.StatusOK)
|
|
return
|
|
}
|
|
c.Writer.Write([]byte("not ready"))
|
|
c.AbortWithStatus(http.StatusServiceUnavailable)
|
|
return errors.New("not ready")
|
|
}
|
|
}
|