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"
|
"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) {
|
||||||
|
4
main.go
4
main.go
@ -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")
|
||||||
|
Reference in New Issue
Block a user