package health

import (
	"encoding/json"
	"net/http"
	"time"
)

type response struct {
	Status    string `json:"status"`
	Timestamp string `json:"timestamp"`
}

// Handler returns HTTP 200 with a JSON body {"status":"ok","timestamp":"..."}.
// Used by load balancers, Docker healthchecks, and Kubernetes liveness probes.
func Handler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)
	_ = json.NewEncoder(w).Encode(response{
		Status:    "ok",
		Timestamp: time.Now().UTC().Format(time.RFC3339),
	})
}
