feat: add default reply to get on / and health check on /healthz

This commit is contained in:
2025-05-16 10:41:56 +02:00
parent a8ef10f97d
commit 3c0f1bd531
2 changed files with 10 additions and 1 deletions

View File

@ -5,8 +5,15 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "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 // handler generates the echo server response
func handler(l int) http.HandlerFunc { func handler(l int) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {

View File

@ -15,7 +15,9 @@ func main() {
r := mux.NewRouter() r := mux.NewRouter()
r.HandleFunc("/", handler(l)). r.HandleFunc("/", handler(l)).
Methods("POST") Methods("POST")
r.HandleFunc("/healthz", httpHealth(l)). r.HandleFunc("/", ok).
Methods("GET")
r.HandleFunc("/healthz{slash:/?}", httpHealth(l)).
Methods("GET") Methods("GET")
r.HandleFunc("/reset", reset(t)). r.HandleFunc("/reset", reset(t)).
Methods("PUT") Methods("PUT")