From d35c6e77d7317020843ea68b61d56b0685545963 Mon Sep 17 00:00:00 2001 From: Bruce Lee Date: Fri, 19 Aug 2016 12:02:26 -0400 Subject: [PATCH] add PING handler to dashboard API --- docs/toml.md | 20 ++++++++++++++++++++ web.go | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/docs/toml.md b/docs/toml.md index 453536e59..50cad270d 100644 --- a/docs/toml.md +++ b/docs/toml.md @@ -418,6 +418,26 @@ address = ":8080" ![Web UI Providers](img/web.frontend.png) ![Web UI Health](img/traefik-health.png) +- `/ping`: `GET` simple endpoint to check for Træfik process liveness. + +```sh +$ curl -sv "http://localhost:8080/ping" +* Trying ::1... +* Connected to localhost (::1) port 8080 (#0) +> GET /ping HTTP/1.1 +> Host: localhost:8080 +> User-Agent: curl/7.43.0 +> Accept: */* +> +< HTTP/1.1 200 OK +< Date: Thu, 25 Aug 2016 01:35:36 GMT +< Content-Length: 2 +< Content-Type: text/plain; charset=utf-8 +< +* Connection #0 to host localhost left intact +OK +``` + - `/health`: `GET` json metrics ```sh diff --git a/web.go b/web.go index 048ffa121..bb0646b5e 100644 --- a/web.go +++ b/web.go @@ -52,6 +52,8 @@ func (provider *WebProvider) Provide(configurationChan chan<- types.ConfigMessag // health route systemRouter.Methods("GET").Path("/health").HandlerFunc(provider.getHealthHandler) + // ping route + systemRouter.Methods("GET").Path("/ping").HandlerFunc(provider.getPingHandler) // API routes systemRouter.Methods("GET").Path("/api").HandlerFunc(provider.getConfigHandler) systemRouter.Methods("GET").Path("/api/providers").HandlerFunc(provider.getConfigHandler) @@ -120,6 +122,10 @@ func (provider *WebProvider) getHealthHandler(response http.ResponseWriter, requ templatesRenderer.JSON(response, http.StatusOK, metrics.Data()) } +func (provider *WebProvider) getPingHandler(response http.ResponseWriter, request *http.Request) { + fmt.Fprintf(response, "OK") +} + func (provider *WebProvider) getConfigHandler(response http.ResponseWriter, request *http.Request) { currentConfigurations := provider.server.currentConfigurations.Get().(configs) templatesRenderer.JSON(response, http.StatusOK, currentConfigurations)