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 <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-09-04 22:42:46 -07:00
parent efef44c2d7
commit 0f23d6bbf9
No known key found for this signature in database
GPG key ID: 5C02521D7B216AD6
2 changed files with 3 additions and 2 deletions

View file

@ -30,7 +30,7 @@ spec:
readinessProbe: readinessProbe:
initialDelaySeconds: 10 initialDelaySeconds: 10
httpGet: httpGet:
path: "/" path: "/_healthz"
port: 8080 port: 8080
httpHeaders: httpHeaders:
- name: "Cookie" - name: "Cookie"

View file

@ -121,7 +121,8 @@ func main() {
r.HandleFunc("/logout", svc.logoutHandler).Methods(http.MethodGet) r.HandleFunc("/logout", svc.logoutHandler).Methods(http.MethodGet)
r.HandleFunc("/cart/checkout", svc.placeOrderHandler).Methods(http.MethodPost) r.HandleFunc("/cart/checkout", svc.placeOrderHandler).Methods(http.MethodPost)
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/")))) 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 var handler http.Handler = r
handler = &logHandler{log: log, next: handler} // add logging handler = &logHandler{log: log, next: handler} // add logging