MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / apiPatchConfig

Method apiPatchConfig

modules/fishing/admin_api.go:15–32  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

13}
14
15func (m *FishingModule) apiPatchConfig(r *http.Request) (int, bool, any) {
16 var body struct {
17 FishingRodItemIds []int `json:"fishingroditems"`
18 }
19 if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
20 return http.StatusBadRequest, false, map[string]string{"error": "malformed request body: " + err.Error()}
21 }
22
23 if body.FishingRodItemIds == nil {
24 body.FishingRodItemIds = []int{}
25 }
26 m.cfg.FishingRodItemIds = body.FishingRodItemIds
27 if err := m.plug.WriteStruct(configKey, m.cfg); err != nil {
28 return http.StatusInternalServerError, false, map[string]string{"error": "failed to save config: " + err.Error()}
29 }
30
31 return http.StatusOK, true, map[string]string{"status": "saved"}
32}
33
34func (m *FishingModule) apiGetCatchables(r *http.Request) (int, bool, any) {
35 catchables := m.cfg.Catchables

Callers

nothing calls this directly

Calls 1

WriteStructMethod · 0.80

Tested by

no test coverage detected