feat: add default reply to get on / and health check on /healthz
This commit is contained in:
7
gecho.go
7
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) {
|
||||
|
4
main.go
4
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")
|
||||
|
Reference in New Issue
Block a user