forked from topfreegames/khan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
status.go
34 lines (29 loc) · 786 Bytes
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// khan
// https://github.com/topfreegames/khan
//
// Licensed under the MIT license:
// http://www.opensource.org/licenses/mit-license
// Copyright © 2016 Top Free Games <backend@tfgco.com>
package api
import (
"encoding/json"
"net/http"
"github.com/labstack/echo"
)
//StatusHandler is the handler responsible for reporting khan status
func StatusHandler(app *App) func(c echo.Context) error {
return func(c echo.Context) error {
c.Set("route", "Status")
payload := map[string]interface{}{
"app": map[string]interface{}{
"errorRate": app.Errors.Rate(),
},
}
var payloadJSON []byte
WithSegment("response-marshalling", c, func() error {
payloadJSON, _ = json.Marshal(payload)
return nil
})
return c.String(http.StatusOK, string(payloadJSON))
}
}