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:
parent
21d467a284
commit
cc8974d6b7
1 changed files with 6 additions and 0 deletions
6
main.go
6
main.go
|
|
@ -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() {
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
|
|
@ -200,6 +205,7 @@ func main() {
|
|||
}
|
||||
|
||||
http.HandleFunc("/vector", vectorHandler)
|
||||
http.HandleFunc("/ok", healthHandler)
|
||||
log.Printf("Starting server on port %s...\n", port)
|
||||
log.Fatal(http.ListenAndServe(":"+port, nil))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue