summaryrefslogtreecommitdiffstats
path: root/api4/system.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-16 14:59:44 -0400
committerCorey Hulen <corey@hulen.com>2017-03-16 11:59:44 -0700
commit0bc3e46082d9018188262f9cb8fdbc206d0656a0 (patch)
tree4ea3c374fff76fe12ad5f325987866baa69cea09 /api4/system.go
parent24848f9d6a92eb1e09189c358636fd1ba32fa6d6 (diff)
downloadchat-0bc3e46082d9018188262f9cb8fdbc206d0656a0.tar.gz
chat-0bc3e46082d9018188262f9cb8fdbc206d0656a0.tar.bz2
chat-0bc3e46082d9018188262f9cb8fdbc206d0656a0.zip
Implement GET /logs endpoint for APIv4 (#5778)
Diffstat (limited to 'api4/system.go')
-rw-r--r--api4/system.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/api4/system.go b/api4/system.go
index d33be0c66..f12d802ef 100644
--- a/api4/system.go
+++ b/api4/system.go
@@ -21,6 +21,8 @@ func InitSystem() {
BaseRoutes.ApiRoot.Handle("/email/test", ApiSessionRequired(testEmail)).Methods("POST")
BaseRoutes.ApiRoot.Handle("/database/recycle", ApiSessionRequired(databaseRecycle)).Methods("POST")
BaseRoutes.ApiRoot.Handle("/caches/invalidate", ApiSessionRequired(invalidateCaches)).Methods("POST")
+
+ BaseRoutes.ApiRoot.Handle("/logs", ApiSessionRequired(getLogs)).Methods("GET")
}
func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -94,3 +96,18 @@ func invalidateCaches(c *Context, w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
ReturnStatusOK(w)
}
+
+func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
+ if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
+ c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
+ return
+ }
+
+ lines, err := app.GetLogs(c.Params.Page, c.Params.PerPage)
+ if err != nil {
+ c.Err = err
+ return
+ }
+
+ w.Write([]byte(model.ArrayToJson(lines)))
+}