feat: refactoring

This commit is contained in:
2025-05-17 20:32:53 +02:00
parent 956037fc03
commit fab01674d5
7 changed files with 364 additions and 330 deletions

28
pkg/http/handle_system.go Normal file
View File

@@ -0,0 +1,28 @@
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"})
}