From 35d902c7a7df6e7bdaa36436ef030d6418af4c77 Mon Sep 17 00:00:00 2001 From: Rhea Danzey Date: Tue, 29 Aug 2023 13:14:17 -0500 Subject: [PATCH] Add a simple health check endpoint to satisfy k8s needs (#11) --- main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.go b/main.go index 80899eb..29ef463 100644 --- a/main.go +++ b/main.go @@ -72,6 +72,17 @@ func exchangeOIDCToken( return &userinfo, nil } +func (h *Handler) healthcheck(w http.ResponseWriter, r *http.Request) { + log.Printf("Health check from %s", r.RemoteAddr) + + if r.Method == "GET" { + w.WriteHeader(http.StatusOK) + return + } else { + w.WriteHeader(http.StatusMethodNotAllowed) + } +} + func (h *Handler) handle(w http.ResponseWriter, r *http.Request) { log.Printf("Request from %s", r.RemoteAddr) @@ -172,6 +183,8 @@ func main() { } http.HandleFunc("/sfu/get", handler.handle) + http.HandleFunc("/healthz", handler.healthcheck) + log.Fatal(http.ListenAndServe(":8080", nil)) }