package main import ( "encoding/json" "net/http" "strings" "imuslab.com/bokofs/bokofsd/mod/utils" ) /* raid.go This file handles the RAID management and monitoring API routing */ func HandleRAIDCalls() http.Handler { return http.StripPrefix("/raid/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { pathParts := strings.Split(r.URL.Path, "/") switch pathParts[0] { case "list": // List all RAID devices raidManager.HandleListRaidDevices(w, r) return case "sync": // Get the RAID sync state, require "dev=md0" as a query parameter raidManager.HandleGetRAIDSyncState(w, r) return case "test": ss, err := raidManager.GetSyncStates() if err != nil { http.Error(w, "Internal Server Error", http.StatusInternalServerError) return } js, _ := json.Marshal(ss) utils.SendJSONResponse(w, string(js)) return default: http.Error(w, "Not Found", http.StatusNotFound) return } })) }