veylant/internal/health/handler.go
2026-02-23 13:35:04 +01:00

24 lines
577 B
Go

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),
})
}