PATCH /admin/api/v2/spells/{spellId}
(w http.ResponseWriter, r *http.Request)
| 75 | |
| 76 | // PATCH /admin/api/v2/spells/{spellId} |
| 77 | func apiV2PatchSpell(w http.ResponseWriter, r *http.Request) { |
| 78 | spellId := r.PathValue("spellId") |
| 79 | existing := spells.GetSpell(spellId) |
| 80 | if existing == nil { |
| 81 | writeAPIError(w, http.StatusNotFound, "spell not found: "+spellId) |
| 82 | return |
| 83 | } |
| 84 | |
| 85 | updated := *existing |
| 86 | if err := json.NewDecoder(r.Body).Decode(&updated); err != nil { |
| 87 | writeAPIError(w, http.StatusBadRequest, "malformed request body: "+err.Error()) |
| 88 | return |
| 89 | } |
| 90 | |
| 91 | updated.SpellId = spellId |
| 92 | |
| 93 | if err := spells.SaveSpellSpec(&updated); err != nil { |
| 94 | writeAPIError(w, http.StatusInternalServerError, err.Error()) |
| 95 | return |
| 96 | } |
| 97 | |
| 98 | writeJSON(w, http.StatusOK, APIResponse[*spells.SpellData]{ |
| 99 | Success: true, |
| 100 | Data: &updated, |
| 101 | }) |
| 102 | } |
| 103 | |
| 104 | // DELETE /admin/api/v2/spells/{spellId} |
| 105 | func apiV2DeleteSpell(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected