diff --git a/controller/internal/api/router.go b/controller/internal/api/router.go index 3b8c263..be6ba35 100644 --- a/controller/internal/api/router.go +++ b/controller/internal/api/router.go @@ -63,6 +63,18 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { case strings.HasPrefix(path, "/stacks/") && req.Method == http.MethodGet && !hasSubpath(path, "/stacks/"): r.getStack(w, req, trimSegment(path, "/stacks/")) + // GET /api/selfupdate/status — must be before hasSuffix-based stack cases + case path == "/selfupdate/status" && req.Method == http.MethodGet: + r.selfupdateStatus(w, req) + + // POST /api/selfupdate/check — must be before hasSuffix-based stack cases + case path == "/selfupdate/check" && req.Method == http.MethodPost: + r.selfupdateCheck(w, req) + + // POST /api/selfupdate/update — must be before hasSuffix("/update") stack case + case path == "/selfupdate/update" && req.Method == http.MethodPost: + r.selfupdateTrigger(w, req) + // GET /api/stacks/{name}/deploy-fields case hasSuffix(path, "/deploy-fields") && req.Method == http.MethodGet: r.getDeployFields(w, req, extractName(path, "/deploy-fields")) @@ -156,18 +168,6 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { case path == "/metrics/sysinfo" && req.Method == http.MethodGet: r.metricsSysInfo(w, req) - // GET /api/selfupdate/status - case path == "/selfupdate/status" && req.Method == http.MethodGet: - r.selfupdateStatus(w, req) - - // POST /api/selfupdate/check - case path == "/selfupdate/check" && req.Method == http.MethodPost: - r.selfupdateCheck(w, req) - - // POST /api/selfupdate/update - case path == "/selfupdate/update" && req.Method == http.MethodPost: - r.selfupdateTrigger(w, req) - default: writeJSON(w, http.StatusNotFound, apiResponse{OK: false, Error: "endpoint not found"}) }