PUT /admin/api/v2/spells/{spellId}/script
(w http.ResponseWriter, r *http.Request)
| 134 | |
| 135 | // PUT /admin/api/v2/spells/{spellId}/script |
| 136 | func apiV2PutSpellScript(w http.ResponseWriter, r *http.Request) { |
| 137 | spellId := r.PathValue("spellId") |
| 138 | if spells.GetSpell(spellId) == nil { |
| 139 | writeAPIError(w, http.StatusNotFound, "spell not found: "+spellId) |
| 140 | return |
| 141 | } |
| 142 | |
| 143 | var body struct { |
| 144 | Script string `json:"script"` |
| 145 | } |
| 146 | if err := json.NewDecoder(r.Body).Decode(&body); err != nil { |
| 147 | writeAPIError(w, http.StatusBadRequest, "malformed request body: "+err.Error()) |
| 148 | return |
| 149 | } |
| 150 | |
| 151 | if err := spells.SaveSpellScript(spellId, body.Script); err != nil { |
| 152 | writeAPIError(w, http.StatusInternalServerError, err.Error()) |
| 153 | return |
| 154 | } |
| 155 | |
| 156 | scripting.InvalidateSpellVM(spellId) |
| 157 | |
| 158 | writeJSON(w, http.StatusOK, APIResponse[struct{}]{Success: true}) |
| 159 | } |
nothing calls this directly
no test coverage detected