PUT /admin/api/v1/buffs/{buffId}/script
(w http.ResponseWriter, r *http.Request)
| 114 | |
| 115 | // PUT /admin/api/v1/buffs/{buffId}/script |
| 116 | func apiV1PutBuffScript(w http.ResponseWriter, r *http.Request) { |
| 117 | buffId, ok := resolveBuffId(w, r.PathValue("buffId")) |
| 118 | if !ok { |
| 119 | return |
| 120 | } |
| 121 | |
| 122 | var body struct { |
| 123 | Script string `json:"script"` |
| 124 | } |
| 125 | if err := json.NewDecoder(r.Body).Decode(&body); err != nil { |
| 126 | writeAPIError(w, http.StatusBadRequest, "malformed request body: "+err.Error()) |
| 127 | return |
| 128 | } |
| 129 | |
| 130 | if err := buffs.SaveBuffScript(buffId, body.Script); err != nil { |
| 131 | writeAPIError(w, http.StatusInternalServerError, err.Error()) |
| 132 | return |
| 133 | } |
| 134 | |
| 135 | scripting.InvalidateBuffVM(buffId) |
| 136 | |
| 137 | writeJSON(w, http.StatusOK, APIResponse[struct{}]{Success: true}) |
| 138 | } |
nothing calls this directly
no test coverage detected