From 82256a3f6f0bb2ac76714a0ff5a90b4cfcee70ba Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 12 Dec 2025 11:47:04 -0500 Subject: [PATCH] Add healthcheck route --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index 10950e1..cb2bf3c 100644 --- a/main.go +++ b/main.go @@ -382,6 +382,7 @@ func main() { http.HandleFunc("/update-proxy-mapping", handleUpdateProxyMapping) http.HandleFunc("/update-destinations", handleUpdateDestinations) http.HandleFunc("/update-local-snis", handleUpdateLocalSNIs) + http.HandleFunc("/healthz", handleHealthz) logger.Info("Starting HTTP server on %s", listenAddr) // HTTP server with graceful shutdown on context cancel @@ -833,6 +834,15 @@ func handlePeer(w http.ResponseWriter, r *http.Request) { } } +func handleHealthz(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return + } + w.WriteHeader(http.StatusOK) + _, _ = w.Write([]byte("ok")) +} + func handleAddPeer(w http.ResponseWriter, r *http.Request) { var peer Peer if err := json.NewDecoder(r.Body).Decode(&peer); err != nil {