MCPcopy Index your code
hub / github.com/Monibuca/engine / API_updateConfig

Method API_updateConfig

http.go:154–185  ·  view source on GitHub ↗

API_updateConfig 热更新配置

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

152
153// API_updateConfig 热更新配置
154func (conf *GlobalConfig) API_updateConfig(w http.ResponseWriter, r *http.Request) {
155 var p *Plugin
156 var q = r.URL.Query()
157 if configName := q.Get("name"); configName != "" {
158 if c, ok := Plugins[configName]; ok {
159 p = c
160 } else {
161 util.ReturnError(util.APIErrorNoConfig, NO_SUCH_CONIFG, w, r)
162 return
163 }
164 } else {
165 p = Engine
166 }
167 var err error
168 var modified map[string]any
169 if q.Get("yaml") != "" {
170 err = yaml.NewDecoder(r.Body).Decode(&modified)
171 } else {
172 err = json.NewDecoder(r.Body).Decode(&modified)
173 }
174 if err != nil {
175 util.ReturnError(util.APIErrorDecode, err.Error(), w, r)
176 return
177 }
178 p.RawConfig.ParseModifyFile(modified)
179 if err = p.Save(); err != nil {
180 util.ReturnError(util.APIErrorSave, err.Error(), w, r)
181 return
182 }
183 p.Update(&p.RawConfig)
184 util.ReturnOK(w, r)
185}
186
187func (conf *GlobalConfig) API_list_pull(w http.ResponseWriter, r *http.Request) {
188 util.ReturnFetchValue(func() (result []any) {

Callers

nothing calls this directly

Calls 7

SaveMethod · 0.95
UpdateMethod · 0.95
ReturnErrorFunction · 0.92
ReturnOKFunction · 0.92
ParseModifyFileMethod · 0.80
ErrorMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected