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

Function apiV2PatchSpell

internal/web/api_v2_spells.go:77–102  ·  view source on GitHub ↗

PATCH /admin/api/v2/spells/{spellId}

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

Source from the content-addressed store, hash-verified

75
76// PATCH /admin/api/v2/spells/{spellId}
77func 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}
105func apiV2DeleteSpell(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 4

GetSpellFunction · 0.92
SaveSpellSpecFunction · 0.92
writeAPIErrorFunction · 0.85
writeJSONFunction · 0.85

Tested by

no test coverage detected