Pārlūkot izejas kodu

Export a new status variable for unlicensed server

gabrielseibel1 2 gadi atpakaļ
vecāks
revīzija
9e520b69a0
2 mainītis faili ar 9 papildinājumiem un 14 dzēšanām
  1. 6 12
      controllers/server.go
  2. 3 2
      servercfg/serverconf.go

+ 6 - 12
controllers/server.go

@@ -68,22 +68,16 @@ func getUsage(w http.ResponseWriter, r *http.Request) {
 //			Responses:
 //				200: serverConfigResponse
 func getStatus(w http.ResponseWriter, r *http.Request) {
-	// TODO
-	// - check health of broker
 	type status struct {
-		DB     bool `json:"db_connected"`
-		Broker bool `json:"broker_connected"`
-		Usage  struct {
-			Hosts    int `json:"hosts"`
-			Clients  int `json:"clients"`
-			Networks int `json:"networks"`
-			Users    int `json:"users"`
-		} `json:"usage"`
+		DB           bool `json:"db_connected"`
+		Broker       bool `json:"broker_connected"`
+		UnlicensedEE bool `json:"unlicensed_ee"`
 	}
 
 	currentServerStatus := status{
-		DB:     database.IsConnected(),
-		Broker: mq.IsConnected(),
+		DB:           database.IsConnected(),
+		Broker:       mq.IsConnected(),
+		UnlicensedEE: servercfg.Is_EE && servercfg.IsUnlicensed,
 	}
 
 	w.Header().Set("Content-Type", "application/json")

+ 3 - 2
servercfg/serverconf.go

@@ -18,8 +18,9 @@ import (
 const EmqxBrokerType = "emqx"
 
 var (
-	Version = "dev"
-	Is_EE   = false
+	Version      = "dev"
+	Is_EE        = false
+	IsUnlicensed = false
 )
 
 // SetHost - sets the host ip