fix: move selfupdate routes before hasSuffix stack cases in router
The selfupdate routes were placed after the generic hasSuffix(path, "/update") stack case, which was catching /selfupdate/update before the specific case could match it. Moving the selfupdate cases to before all hasSuffix-based cases fixes the routing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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/"):
|
case strings.HasPrefix(path, "/stacks/") && req.Method == http.MethodGet && !hasSubpath(path, "/stacks/"):
|
||||||
r.getStack(w, req, trimSegment(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
|
// GET /api/stacks/{name}/deploy-fields
|
||||||
case hasSuffix(path, "/deploy-fields") && req.Method == http.MethodGet:
|
case hasSuffix(path, "/deploy-fields") && req.Method == http.MethodGet:
|
||||||
r.getDeployFields(w, req, extractName(path, "/deploy-fields"))
|
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:
|
case path == "/metrics/sysinfo" && req.Method == http.MethodGet:
|
||||||
r.metricsSysInfo(w, req)
|
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:
|
default:
|
||||||
writeJSON(w, http.StatusNotFound, apiResponse{OK: false, Error: "endpoint not found"})
|
writeJSON(w, http.StatusNotFound, apiResponse{OK: false, Error: "endpoint not found"})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user