add memory get func , add memory view route

This commit is contained in:
Jay
2019-02-20 11:37:26 +08:00
parent 36dd396b31
commit afc0987d40
2 changed files with 60 additions and 0 deletions
+7
View File
@@ -6,6 +6,7 @@ import (
"git.trj.tw/golang/mtfosbot/module/config"
"git.trj.tw/golang/mtfosbot/module/context"
"git.trj.tw/golang/mtfosbot/module/utils"
"git.trj.tw/golang/mtfosbot/router/api"
"git.trj.tw/golang/mtfosbot/router/google"
"git.trj.tw/golang/mtfosbot/router/line"
@@ -67,6 +68,12 @@ func SetRoutes(r *gin.Engine) {
apiGroup := r.Group("/api")
{
apiGroup.GET("/memory", func(c *gin.Context) {
mem := utils.GetMemoryUsage()
c.JSON(200, gin.H{
"runtime": utils.ToMap(mem),
})
})
apiGroup.POST("/login", context.PatchCtx(api.UserLogin))
apiGroup.POST("/logout", context.PatchCtx(api.UserLogout))
apiGroup.GET("/line/logs", context.PatchCtx(api.CheckSession), context.PatchCtx(api.GetLineMessageLog))