raid.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 "overview":
  23. // Render the RAID overview page
  24. raidManager.HandleRenderOverview(w, r)
  25. return
  26. case "sync":
  27. // Get the RAID sync state, require "dev=md0" as a query parameter
  28. raidManager.HandleGetRAIDSyncState(w, r)
  29. return
  30. case "start-resync":
  31. // Activate a RAID device, require "dev=md0" as a query parameter
  32. raidManager.HandleSyncPendingToReadWrite(w, r)
  33. return
  34. default:
  35. http.Error(w, "Not Found", http.StatusNotFound)
  36. return
  37. }
  38. }))
  39. }