mirror of
https://github.com/0x1d/rcond.git
synced 2025-12-14 18:25:21 +01:00
29 lines
690 B
Go
29 lines
690 B
Go
package http
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/0x1d/rcond/pkg/system"
|
|
)
|
|
|
|
func HandleReboot(w http.ResponseWriter, r *http.Request) {
|
|
if err := system.Restart(); err != nil {
|
|
WriteError(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(map[string]string{"status": "success"})
|
|
}
|
|
|
|
func HandleShutdown(w http.ResponseWriter, r *http.Request) {
|
|
if err := system.Shutdown(); err != nil {
|
|
WriteError(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(map[string]string{"status": "success"})
|
|
}
|