aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2016-10-11 13:44:33 (UTC)
committerjan <jan@ruken.pw>2016-10-11 13:44:33 (UTC)
commitce75957e592c0dcba21e3c7c952c72530fd388e9 (patch)
tree7e4965bccb2e9f16dc29313c8abe1740bf628616
parentbf51b2e4a035a988b9e9cef737966846c619dace (diff)
/health route zum anzeigen von mem usage und offene db connections
-rw-r--r--grilist/health.go16
-rw-r--r--main.go1
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 @@
1package grilist
2
3import (
4 "fmt"
5 "net/http"
6 "runtime"
7
8 "github.com/julienschmidt/httprouter"
9)
10
11func (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}
diff --git a/main.go b/main.go
index 68a9ede..9231f7c 100644
--- a/main.go
+++ b/main.go
@@ -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)