diff options
-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) |