diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-03-13 12:49:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-13 12:49:19 -0400 |
commit | 59d06b5c56f487570867cdc8b87b2e29c04d450f (patch) | |
tree | bbefc2d11719fe778e9c07cb3bffd159a806373b /api4/cluster.go | |
parent | 27d2c1f6febdc6b80f60837086ebe0c08f975147 (diff) | |
download | chat-59d06b5c56f487570867cdc8b87b2e29c04d450f.tar.gz chat-59d06b5c56f487570867cdc8b87b2e29c04d450f.tar.bz2 chat-59d06b5c56f487570867cdc8b87b2e29c04d450f.zip |
Implement GET /cluster/status endpoint for APIv4 (#5732)
Diffstat (limited to 'api4/cluster.go')
-rw-r--r-- | api4/cluster.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/api4/cluster.go b/api4/cluster.go new file mode 100644 index 000000000..dbf198590 --- /dev/null +++ b/api4/cluster.go @@ -0,0 +1,29 @@ +// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package api4 + +import ( + "net/http" + + l4g "github.com/alecthomas/log4go" + "github.com/mattermost/platform/app" + "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" +) + +func InitCluster() { + l4g.Debug(utils.T("api.cluster.init.debug")) + + BaseRoutes.Cluster.Handle("/status", ApiSessionRequired(getClusterStatus)).Methods("GET") +} + +func getClusterStatus(c *Context, w http.ResponseWriter, r *http.Request) { + if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) { + c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM) + return + } + + infos := app.GetClusterStatus() + w.Write([]byte(model.ClusterInfosToJson(infos))) +} |