mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
20 lines
375 B
Go
20 lines
375 B
Go
package controllers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
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)
|
|
return
|
|
}
|
|
_, _ = c.Writer.Write([]byte("not ready"))
|
|
c.AbortWithStatus(http.StatusServiceUnavailable)
|
|
}
|
|
}
|