From 0f23d6bbf9ac1f7b9f5f8e19cf71fa83f9d62d0b Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Tue, 4 Sep 2018 22:42:46 -0700 Subject: [PATCH] frontend: add simple /healthz endpoint Decouple frontend health checks from GET /, which relies on other services to be reachable. See #34. Closes #34. Signed-off-by: Ahmet Alp Balkan --- kubernetes-manifests/frontend.yaml | 2 +- src/frontend/main.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kubernetes-manifests/frontend.yaml b/kubernetes-manifests/frontend.yaml index 4f62e77..d921a8f 100644 --- a/kubernetes-manifests/frontend.yaml +++ b/kubernetes-manifests/frontend.yaml @@ -30,7 +30,7 @@ spec: readinessProbe: initialDelaySeconds: 10 httpGet: - path: "/" + path: "/_healthz" port: 8080 httpHeaders: - name: "Cookie" diff --git a/src/frontend/main.go b/src/frontend/main.go index c3dd3c7..dccf4c8 100644 --- a/src/frontend/main.go +++ b/src/frontend/main.go @@ -121,7 +121,8 @@ func main() { r.HandleFunc("/logout", svc.logoutHandler).Methods(http.MethodGet) r.HandleFunc("/cart/checkout", svc.placeOrderHandler).Methods(http.MethodPost) r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/")))) - r.HandleFunc("/robots.txt", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "User-agent: *\nDisallow: /") }) + r.HandleFunc("/robots.txt", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, "User-agent: *\nDisallow: /") }) + r.HandleFunc("/_healthz", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, "ok") }) var handler http.Handler = r handler = &logHandler{log: log, next: handler} // add logging