27 lines
557 B
Go
27 lines
557 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// statusResponse is the body shape returned by both probes.
|
|
type statusResponse struct {
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
func handleHealthz(c *gin.Context) {
|
|
c.JSON(http.StatusOK, statusResponse{Status: "ok"})
|
|
}
|
|
|
|
func handleReadyz(ready func() bool) gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
if ready != nil && !ready() {
|
|
c.JSON(http.StatusServiceUnavailable, statusResponse{Status: "starting"})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, statusResponse{Status: "ready"})
|
|
}
|
|
}
|