diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2017-04-10 15:28:04 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2017-04-10 15:28:04 +0100 |
commit | da7638dc112c4c106e8929601b642d2ca4596cba (patch) | |
tree | d3bf80471a9588ec3a97d8fae255c56af8f10ebb /server/web.go | |
parent | fae8497fcc0977bd368cce13407a1e79abb3f1c8 (diff) |
add a healthcheck handler
Diffstat (limited to 'server/web.go')
-rw-r--r-- | server/web.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/server/web.go b/server/web.go index 65eca49..edaa394 100644 --- a/server/web.go +++ b/server/web.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "encoding/hex" "encoding/json" + "fmt" "html/template" "io" "log" @@ -248,6 +249,11 @@ func revokeCertHandler(a *appContext, w http.ResponseWriter, r *http.Request) (i return http.StatusSeeOther, nil } +func healthcheck(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + fmt.Fprint(w, "ok") +} + // appHandler is a handler which uses appContext to manage state. type appHandler struct { *appContext @@ -304,6 +310,7 @@ func runHTTPServer(conf *config.Server, l net.Listener) { r.Methods("GET").Path("/admin/certs").Handler(CSRF(appHandler{ctx, listAllCertsHandler})) r.Methods("GET").Path("/admin/certs.json").Handler(appHandler{ctx, listCertsJSONHandler}) r.Methods("GET").Path("/metrics").Handler(promhttp.Handler()) + r.Methods("GET").Path("/healthcheck").HandlerFunc(healthcheck) r.PathPrefix("/").Handler(http.FileServer(static.FS(false))) h := handlers.LoggingHandler(logfile, r) s := &http.Server{ |