diff options
| author | jan <jan@ruken.pw> | 2016-10-11 13:44:33 (UTC) |
|---|---|---|
| committer | jan <jan@ruken.pw> | 2016-10-11 13:44:33 (UTC) |
| commit | ce75957e592c0dcba21e3c7c952c72530fd388e9 (patch) | |
| tree | 7e4965bccb2e9f16dc29313c8abe1740bf628616 | |
| parent | bf51b2e4a035a988b9e9cef737966846c619dace (diff) | |
/health route zum anzeigen von mem usage und offene db connections
| -rw-r--r-- | grilist/health.go | 16 | ||||
| -rw-r--r-- | main.go | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/grilist/health.go b/grilist/health.go new file mode 100644 index 0000000..15697ea --- /dev/null +++ b/grilist/health.go | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | package grilist | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "fmt" | ||
| 5 | "net/http" | ||
| 6 | "runtime" | ||
| 7 | |||
| 8 | "github.com/julienschmidt/httprouter" | ||
| 9 | ) | ||
| 10 | |||
| 11 | func (g *Grilist) HealthCheck(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
| 12 | var mem runtime.MemStats | ||
| 13 | runtime.ReadMemStats(&mem) | ||
| 14 | |||
| 15 | w.Write([]byte(fmt.Sprintf("mem in use: %d\nopen g.DB connections: %d", mem.Alloc, g.DB.Stats().OpenConnections))) | ||
| 16 | } | ||
| @@ -68,6 +68,7 @@ func main() { | |||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | router.GET("/", index) | 70 | router.GET("/", index) |
| 71 | router.GET("/health", app.HealthCheck) | ||
| 71 | router.HandlerFunc("GET", "/login", login.DisplayLogin) | 72 | router.HandlerFunc("GET", "/login", login.DisplayLogin) |
| 72 | router.HandlerFunc("POST", "/login", login.Login) | 73 | router.HandlerFunc("POST", "/login", login.Login) |
| 73 | router.HandlerFunc("GET", "/settings", login.DisplayUserSettings) | 74 | router.HandlerFunc("GET", "/settings", login.DisplayUserSettings) |
