mirror of
https://github.com/0x1d/rcond.git
synced 2025-12-16 10:54:29 +01:00
feat: introduce cluster agent
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/0x1d/rcond/pkg/cluster"
|
||||
network "github.com/0x1d/rcond/pkg/network"
|
||||
"github.com/0x1d/rcond/pkg/system"
|
||||
"github.com/0x1d/rcond/pkg/user"
|
||||
@@ -287,3 +288,24 @@ func HandleShutdown(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{"status": "success"})
|
||||
}
|
||||
|
||||
func ClusterAgentWrapper(agent *cluster.Agent) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
HandleClusterMembers(w, r, agent)
|
||||
}
|
||||
}
|
||||
|
||||
func HandleClusterMembers(w http.ResponseWriter, r *http.Request, agent *cluster.Agent) {
|
||||
if agent == nil {
|
||||
writeError(w, "cluster agent is not initialized", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
members, err := agent.Members()
|
||||
if err != nil {
|
||||
writeError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(members)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user