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

Method apiDeleteCatchable

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

Source from the content-addressed store, hash-verified

97}
98
99func (m *FishingModule) apiDeleteCatchable(r *http.Request) (int, bool, any) {
100 idStr := r.PathValue("id")
101 if idStr == "" {
102 idStr = r.URL.Query().Get("id")
103 }
104
105 id, err := strconv.Atoi(idStr)
106 if err != nil || id < 1 {
107 return http.StatusBadRequest, false, map[string]string{"error": "valid id is required"}
108 }
109
110 for i, c := range m.cfg.Catchables {
111 if c.ID == id {
112 m.cfg.Catchables = append(m.cfg.Catchables[:i], m.cfg.Catchables[i+1:]...)
113 if err := m.plug.WriteStruct(configKey, m.cfg); err != nil {
114 return http.StatusInternalServerError, false, map[string]string{"error": "failed to save: " + err.Error()}
115 }
116 return http.StatusOK, true, map[string]string{"status": "deleted"}
117 }
118 }
119
120 return http.StatusNotFound, false, map[string]string{"error": "catchable not found"}
121}

Callers

nothing calls this directly

Calls 2

WriteStructMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected