feat(cloudflare): 新增全局托管开关并发布 v1.8.0
CI / verify (push) Canceled after 0s

This commit is contained in:
2026-09-30 11:56:56 +08:00
parent 1434cfd72b
commit 2d0f63517b
17 changed files with 198 additions and 27 deletions
+16
View File
@@ -207,6 +207,22 @@ func (h *CloudflareHandler) TestToken(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, map[string]any{"ok": true, "message": message})
}
func (h *CloudflareHandler) SetEnabled(w http.ResponseWriter, r *http.Request) {
var request struct {
Enabled bool `json:"enabled"`
}
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 4<<10)).Decode(&request); err != nil {
writeError(r, w, http.StatusBadRequest, "请求格式无效")
return
}
settings, err := h.svc.SetEnabled(r.Context(), request.Enabled)
if err != nil {
writeError(r, w, http.StatusBadGateway, err.Error())
return
}
writeJSON(w, http.StatusOK, settings)
}
func (h *CloudflareHandler) DownloadBinary(w http.ResponseWriter, r *http.Request) {
var request struct {
Mirror string `json:"mirror"`
+1
View File
@@ -209,6 +209,7 @@ func newRouterWithSpecs(deps Deps) (http.Handler, []routeSpec) {
protect("GET /api/cloudflare/settings", cf.AppSettings)
protect("PUT /api/cloudflare/settings", cf.SaveAppSettings)
protect("POST /api/cloudflare/settings/test", cf.TestToken)
protect("POST /api/cloudflare/enabled", cf.SetEnabled)
protect("GET /api/cloudflare/ingress-candidates", cf.IngressCandidates)
}