raid.go 972 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "net/http"
  4. "strings"
  5. )
  6. /*
  7. raid.go
  8. This file handles the RAID management and monitoring API routing
  9. */
  10. func HandleRAIDCalls() http.Handler {
  11. return http.StripPrefix("/raid/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  12. pathParts := strings.Split(r.URL.Path, "/")
  13. switch pathParts[0] {
  14. case "list":
  15. // List all RAID devices
  16. raidManager.HandleListRaidDevices(w, r)
  17. return
  18. case "info":
  19. // Handle loading the detail of a given RAID array, require "dev=md0" as a query parameter
  20. raidManager.HandleLoadArrayDetail(w, r)
  21. return
  22. case "sync":
  23. // Get the RAID sync state, require "dev=md0" as a query parameter
  24. raidManager.HandleGetRAIDSyncState(w, r)
  25. return
  26. case "start-resync":
  27. // Activate a RAID device, require "dev=md0" as a query parameter
  28. raidManager.HandleSyncPendingToReadWrite(w, r)
  29. return
  30. default:
  31. http.Error(w, "Not Found", http.StatusNotFound)
  32. return
  33. }
  34. }))
  35. }