mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-14 18:17:29 +08:00
config api: expose hot-reload field list via query mode
This commit is contained in:
@@ -208,6 +208,20 @@ func (s *RegistryServer) handleWebUIConfig(w http.ResponseWriter, r *http.Reques
|
|||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if r.URL.Query().Get("include_hot_reload_fields") == "1" || strings.EqualFold(strings.TrimSpace(r.URL.Query().Get("mode")), "hot") {
|
||||||
|
var cfg map[string]interface{}
|
||||||
|
if err := json.Unmarshal(b, &cfg); err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
_ = json.NewEncoder(w).Encode(map[string]interface{}{
|
||||||
|
"ok": true,
|
||||||
|
"config": cfg,
|
||||||
|
"hot_reload_fields": hotReloadFieldPaths(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
_, _ = w.Write(b)
|
_, _ = w.Write(b)
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
@@ -409,6 +423,21 @@ func (s *RegistryServer) checkAuth(r *http.Request) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hotReloadFieldPaths() []string {
|
||||||
|
return []string{
|
||||||
|
"logging.*",
|
||||||
|
"sentinel.*",
|
||||||
|
"agents.*",
|
||||||
|
"providers.*",
|
||||||
|
"tools.*",
|
||||||
|
"channels.*",
|
||||||
|
"cron.*",
|
||||||
|
"agents.defaults.heartbeat.*",
|
||||||
|
"agents.defaults.autonomy.*",
|
||||||
|
"gateway.* (except listen address/port may require restart in some environments)",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const webUIHTML = `<!doctype html>
|
const webUIHTML = `<!doctype html>
|
||||||
<html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/>
|
<html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/>
|
||||||
<title>ClawGo WebUI</title>
|
<title>ClawGo WebUI</title>
|
||||||
|
|||||||
Reference in New Issue
Block a user