scrub operation + ZFS Pool CRUD
Some checks failed
CI / test-build (push) Failing after 2m14s

This commit is contained in:
2025-12-15 01:19:44 +07:00
parent 9779b30a65
commit abd8cef10a
9 changed files with 1124 additions and 63 deletions

View File

@@ -60,12 +60,30 @@ func pathParam(r *http.Request, prefix string) string {
// handlePoolOps routes pool operations by method
func (a *App) handlePoolOps(w http.ResponseWriter, r *http.Request) {
// Extract pool name from path like /api/v1/pools/tank
name := pathParam(r, "/api/v1/pools/")
if name == "" {
writeError(w, errors.ErrBadRequest("pool name required"))
return
}
if strings.HasSuffix(r.URL.Path, "/scrub") {
if r.Method == http.MethodPost {
a.handleScrubPool(w, r)
return
} else if r.Method == http.MethodGet {
a.handleGetScrubStatus(w, r)
} else {
writeError(w, errors.NewAPIError(errors.ErrCodeBadRequest, "method not allowed", http.StatusMethodNotAllowed))
}
return
}
if strings.HasSuffix(r.URL.Path, "/export") {
if r.Method == http.MethodPost {
a.handleExportPool(w, r)
} else {
writeError(w, errors.NewAPIError(errors.ErrCodeBadRequest, "method not allowed", http.StatusMethodNotAllowed))
}
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}