initial commit

This commit is contained in:
wt
2026-03-19 14:07:10 +07:00
commit 85d50ee958
26 changed files with 2146 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package api
import (
"encoding/json"
"net/http"
"os"
"up/utils"
)
func ExtlinuxRead(w http.ResponseWriter, req *http.Request) {
if utils.MountDevice() < 0 {
w.Header().Set("Content-Type", "application/json")
http.Error(w, "{\"error\":\"Failed to mount device\"}", http.StatusInternalServerError)
return
}
data, err := os.ReadFile(os.Getenv("MOUNT_POINT") + "/" + os.Getenv("EXTLINUX_FILE"))
if err != nil {
w.Header().Set("Content-Type", "application/json")
http.Error(w, "{\"error\":\"extlinux.conf not found\"}", http.StatusInternalServerError)
return
}
response := map[string]interface{}{
"status": "success",
"content": string(data),
"size": len(data),
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(response); err != nil {
// В случае ошибки кодирования уже ничего не сделать,
// можно только залогировать (здесь опущено для краткости)
}
}