|
@@ -6,8 +6,10 @@ import (
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
"github.com/gorilla/mux"
|
|
|
|
+ "github.com/gravitl/netmaker/database"
|
|
"github.com/gravitl/netmaker/logic"
|
|
"github.com/gravitl/netmaker/logic"
|
|
"github.com/gravitl/netmaker/models"
|
|
"github.com/gravitl/netmaker/models"
|
|
|
|
+ "github.com/gravitl/netmaker/mq"
|
|
"github.com/gravitl/netmaker/servercfg"
|
|
"github.com/gravitl/netmaker/servercfg"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -19,6 +21,35 @@ func serverHandlers(r *mux.Router) {
|
|
}))
|
|
}))
|
|
r.HandleFunc("/api/server/getconfig", allowUsers(http.HandlerFunc(getConfig))).Methods(http.MethodGet)
|
|
r.HandleFunc("/api/server/getconfig", allowUsers(http.HandlerFunc(getConfig))).Methods(http.MethodGet)
|
|
r.HandleFunc("/api/server/getserverinfo", authorize(true, false, "node", http.HandlerFunc(getServerInfo))).Methods(http.MethodGet)
|
|
r.HandleFunc("/api/server/getserverinfo", authorize(true, false, "node", http.HandlerFunc(getServerInfo))).Methods(http.MethodGet)
|
|
|
|
+ r.HandleFunc("/api/server/status", http.HandlerFunc(getStatus)).Methods(http.MethodGet)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// swagger:route GET /api/server/status server getStatus
|
|
|
|
+//
|
|
|
|
+// Get the server configuration.
|
|
|
|
+//
|
|
|
|
+// Schemes: https
|
|
|
|
+//
|
|
|
|
+// Security:
|
|
|
|
+// oauth
|
|
|
|
+//
|
|
|
|
+// 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"`
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ currentServerStatus := status{
|
|
|
|
+ DB: database.IsConnected(),
|
|
|
|
+ Broker: mq.IsConnected(),
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ w.Header().Set("Content-Type", "application/json")
|
|
|
|
+ json.NewEncoder(w).Encode(¤tServerStatus)
|
|
}
|
|
}
|
|
|
|
|
|
// allowUsers - allow all authenticated (valid) users - only used by getConfig, may be able to remove during refactor
|
|
// allowUsers - allow all authenticated (valid) users - only used by getConfig, may be able to remove during refactor
|