feat: backend service
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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"})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user