github.com/mattermost/mattermost-server/v5@v5.39.3/api4/system_local.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See LICENSE.txt for license information. 3 4 package api4 5 6 import ( 7 "encoding/json" 8 "net/http" 9 10 "github.com/mattermost/mattermost-server/v5/audit" 11 "github.com/mattermost/mattermost-server/v5/model" 12 ) 13 14 func (api *API) InitSystemLocal() { 15 api.BaseRoutes.System.Handle("/ping", api.ApiLocal(getSystemPing)).Methods("GET") 16 api.BaseRoutes.ApiRoot.Handle("/logs", api.ApiLocal(getLogs)).Methods("GET") 17 api.BaseRoutes.ApiRoot.Handle("/server_busy", api.ApiLocal(setServerBusy)).Methods("POST") 18 api.BaseRoutes.ApiRoot.Handle("/server_busy", api.ApiLocal(getServerBusyExpires)).Methods("GET") 19 api.BaseRoutes.ApiRoot.Handle("/server_busy", api.ApiLocal(clearServerBusy)).Methods("DELETE") 20 api.BaseRoutes.ApiRoot.Handle("/integrity", api.ApiLocal(localCheckIntegrity)).Methods("POST") 21 } 22 23 func localCheckIntegrity(c *Context, w http.ResponseWriter, r *http.Request) { 24 auditRec := c.MakeAuditRecord("localCheckIntegrity", audit.Fail) 25 defer c.LogAuditRec(auditRec) 26 27 var results []model.IntegrityCheckResult 28 resultsChan := c.App.CheckIntegrity() 29 for result := range resultsChan { 30 results = append(results, result) 31 } 32 33 data, err := json.Marshal(results) 34 if err != nil { 35 c.Err = model.NewAppError("Api4.localCheckIntegrity", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) 36 return 37 } 38 39 auditRec.Success() 40 w.Write(data) 41 }