Add health check endpoint at /ok

- Returns {"status": "ok"} as JSON
- No authentication required
- Useful for Kubernetes liveness/readiness probes

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Christoph Haas 2026-06-28 15:54:58 +02:00
parent 21d467a284
commit cc8974d6b7

View file

@ -193,6 +193,11 @@ func vectorHandler(w http.ResponseWriter, r *http.Request) {
}) })
} }
func healthHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
}
func main() { func main() {
port := os.Getenv("PORT") port := os.Getenv("PORT")
if port == "" { if port == "" {
@ -200,6 +205,7 @@ func main() {
} }
http.HandleFunc("/vector", vectorHandler) http.HandleFunc("/vector", vectorHandler)
http.HandleFunc("/ok", healthHandler)
log.Printf("Starting server on port %s...\n", port) log.Printf("Starting server on port %s...\n", port)
log.Fatal(http.ListenAndServe(":"+port, nil)) log.Fatal(http.ListenAndServe(":"+port, nil))
} }