diff --git a/README.md b/README.md index f93ed57..64cf808 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ Following events are implemented: This example will automatically connect to a WiFi access point with the given SSID and password on the interface "wlan0". ```bash -curl -sSf -X POST "http://rpi-test:8080/network/sta" \ +curl -X POST "http://rpi-test:8080/network/sta" \ -H "Content-Type: application/json" \ -H "X-API-Token: 1234567890" \ -d '{ @@ -187,7 +187,7 @@ curl -sSf -X POST "http://rpi-test:8080/network/sta" \ This example will create an access point on the interface "wlan0" with the given SSID and password. ```bash -curl -sSf -X POST "http://rpi-test:8080/network/ap" \ +curl -X POST "http://rpi-test:8080/network/ap" \ -H "Content-Type: application/json" \ -H "X-API-Token: 1234567890" \ -d '{ @@ -197,3 +197,15 @@ curl -sSf -X POST "http://rpi-test:8080/network/ap" \ "autoconnect": true }' ``` +### Restart the cluster + +This example will restart all nodes in the cluster + +```bash +curl -X POST "http://rpi-test:8080/cluster/event" \ + -H "accept: application/json" \ + -H "X-API-Token: 1234567890" \ + -d '{ + "name": "restart" + }' +``` \ No newline at end of file diff --git a/pkg/http/handlers.go b/pkg/http/handlers.go index 59116cc..34d7644 100644 --- a/pkg/http/handlers.go +++ b/pkg/http/handlers.go @@ -304,6 +304,10 @@ func HandleClusterMembers(w http.ResponseWriter, r *http.Request, agent *cluster } func HandleClusterEvent(w http.ResponseWriter, r *http.Request, agent *cluster.Agent) { + if agent == nil { + writeError(w, "cluster agent is not initialized", http.StatusInternalServerError) + return + } var req clusterEventRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeError(w, err.Error(), http.StatusBadRequest)