From 3c0f1bd5315fbd90fc42a07336a048d1bb42bfa8 Mon Sep 17 00:00:00 2001 From: Thomas Andrade Date: Fri, 16 May 2025 10:41:56 +0200 Subject: [PATCH] feat: add default reply to get on / and health check on /healthz --- gecho.go | 7 +++++++ main.go | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gecho.go b/gecho.go index c9ca388..96fbe16 100644 --- a/gecho.go +++ b/gecho.go @@ -5,8 +5,15 @@ import ( "fmt" "io" "net/http" + "strings" ) +func ok(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Test", "test") + fmt.Fprint(w, strings.Join(r.Header.Values("X-Request-Id"), ",")) + +} + // handler generates the echo server response func handler(l int) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { diff --git a/main.go b/main.go index 9d5bcd2..a162d66 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,9 @@ func main() { r := mux.NewRouter() r.HandleFunc("/", handler(l)). Methods("POST") - r.HandleFunc("/healthz", httpHealth(l)). + r.HandleFunc("/", ok). + Methods("GET") + r.HandleFunc("/healthz{slash:/?}", httpHealth(l)). Methods("GET") r.HandleFunc("/reset", reset(t)). Methods("PUT")