(r *http.Request)
| 97 | } |
| 98 | |
| 99 | func (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 | } |
nothing calls this directly
no test coverage detected