package health

import (
	"net/http"

	"github.com/pfeifferj/container-mom-go/pkg/interfaces"
)

// Handler implements basic health check endpoints for the operator
type Handler struct {
	Operator interfaces.OperatorInterface
}

// Healthz handles liveness probe requests
func (h *Handler) Healthz(w http.ResponseWriter, r *http.Request) {
	w.WriteHeader(http.StatusOK)
}

// Readyz handles readiness probe requests
func (h *Handler) Readyz(w http.ResponseWriter, r *http.Request) {
	// Check MongoDB connection
	if err := h.Operator.GetMongoDB().Ping(r.Context(), nil); err != nil {
		http.Error(w, "MongoDB not ready", http.StatusServiceUnavailable)
		return
	}
	w.WriteHeader(http.StatusOK)
}
