github.com/adacta-ru/mattermost-server@v5.11.1+incompatible/api4/cluster.go (about) 1 // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package api4 5 6 import ( 7 "net/http" 8 9 "github.com/mattermost/mattermost-server/model" 10 ) 11 12 func (api *API) InitCluster() { 13 api.BaseRoutes.Cluster.Handle("/status", api.ApiSessionRequired(getClusterStatus)).Methods("GET") 14 } 15 16 func getClusterStatus(c *Context, w http.ResponseWriter, r *http.Request) { 17 if !c.App.SessionHasPermissionTo(c.App.Session, model.PERMISSION_MANAGE_SYSTEM) { 18 c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM) 19 return 20 } 21 22 if *c.App.Config().ExperimentalSettings.RestrictSystemAdmin { 23 c.Err = model.NewAppError("getClusterStatus", "api.restricted_system_admin", nil, "", http.StatusForbidden) 24 return 25 } 26 27 infos := c.App.GetClusterStatus() 28 w.Write([]byte(model.ClusterInfosToJson(infos))) 29 }