package api import ( "encoding/json" "fmt" "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 { fmt.Errorf("Encoding error: %v", err) } }