package handler import ( "context" "net/http" "time" ) const readyTimeout = time.Second func (h *Handler) Live(w http.ResponseWriter, _ *http.Request) { writeJSON(w, http.StatusOK, healthResponse{Status: "ok"}) } func (h *Handler) Ready(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithTimeout(r.Context(), readyTimeout) defer cancel() for _, dep := range h.deps { if err := dep(ctx); err != nil { h.fail(w, r, err) return } } writeJSON(w, http.StatusOK, healthResponse{Status: "ok"}) }