summaryrefslogtreecommitdiffstats
path: root/api4/system.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-27 09:19:53 -0400
committerChristopher Speller <crspeller@gmail.com>2017-03-27 09:19:53 -0400
commita0d5c01dfd97b45478353ccff777de677f088d0f (patch)
treed4206ef53c44e5ec65fb5b5a01e68d3102e1adf6 /api4/system.go
parentd145c3583835766c1f200a413131e7d6bad82229 (diff)
downloadchat-a0d5c01dfd97b45478353ccff777de677f088d0f.tar.gz
chat-a0d5c01dfd97b45478353ccff777de677f088d0f.tar.bz2
chat-a0d5c01dfd97b45478353ccff777de677f088d0f.zip
Implement client config/license endpoints for APIv4 (#5867)
Diffstat (limited to 'api4/system.go')
-rw-r--r--api4/system.go44
1 files changed, 43 insertions, 1 deletions
diff --git a/api4/system.go b/api4/system.go
index 972d526da..098f7e4b7 100644
--- a/api4/system.go
+++ b/api4/system.go
@@ -17,8 +17,12 @@ func InitSystem() {
BaseRoutes.System.Handle("/ping", ApiHandler(getSystemPing)).Methods("GET")
BaseRoutes.ApiRoot.Handle("/config", ApiSessionRequired(getConfig)).Methods("GET")
- BaseRoutes.ApiRoot.Handle("/config/reload", ApiSessionRequired(configReload)).Methods("POST")
BaseRoutes.ApiRoot.Handle("/config", ApiSessionRequired(updateConfig)).Methods("PUT")
+ BaseRoutes.ApiRoot.Handle("/config/reload", ApiSessionRequired(configReload)).Methods("POST")
+ BaseRoutes.ApiRoot.Handle("/config/client", ApiHandler(getClientConfig)).Methods("GET")
+
+ BaseRoutes.ApiRoot.Handle("/license/client", ApiHandler(getClientLicense)).Methods("GET")
+
BaseRoutes.ApiRoot.Handle("/audits", ApiSessionRequired(getAudits)).Methods("GET")
BaseRoutes.ApiRoot.Handle("/email/test", ApiSessionRequired(testEmail)).Methods("POST")
BaseRoutes.ApiRoot.Handle("/database/recycle", ApiSessionRequired(databaseRecycle)).Methods("POST")
@@ -155,3 +159,41 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(model.ArrayToJson(lines)))
}
+
+func getClientConfig(c *Context, w http.ResponseWriter, r *http.Request) {
+ format := r.URL.Query().Get("format")
+
+ if format == "" {
+ c.Err = model.NewAppError("getClientConfig", "api.config.client.old_format.app_error", nil, "", http.StatusNotImplemented)
+ return
+ }
+
+ if format != "old" {
+ c.SetInvalidParam("format")
+ return
+ }
+
+ w.Write([]byte(model.MapToJson(utils.ClientCfg)))
+}
+
+func getClientLicense(c *Context, w http.ResponseWriter, r *http.Request) {
+ format := r.URL.Query().Get("format")
+
+ if format == "" {
+ c.Err = model.NewAppError("getClientLicense", "api.license.client.old_format.app_error", nil, "", http.StatusNotImplemented)
+ return
+ }
+
+ if format != "old" {
+ c.SetInvalidParam("format")
+ return
+ }
+
+ etag := utils.GetClientLicenseEtag(true)
+ if HandleEtag(etag, "Get Client License", w, r) {
+ return
+ }
+
+ w.Header().Set(model.HEADER_ETAG_SERVER, etag)
+ w.Write([]byte(model.MapToJson(utils.GetSanitizedClientLicense())))
+}