add PING handler to dashboard API

This commit is contained in:
Bruce Lee 2016-08-19 12:02:26 -04:00
parent 1de21c86ae
commit d35c6e77d7
2 changed files with 26 additions and 0 deletions

View file

@ -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

6
web.go
View file

@ -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)