PATCH /admin/api/v1/mutators/{mutatorId}
(w http.ResponseWriter, r *http.Request)
| 54 | |
| 55 | // PATCH /admin/api/v1/mutators/{mutatorId} |
| 56 | func apiV1PatchMutator(w http.ResponseWriter, r *http.Request) { |
| 57 | mutatorId := r.PathValue("mutatorId") |
| 58 | |
| 59 | existing := mutators.GetMutatorSpec(mutatorId) |
| 60 | if existing == nil { |
| 61 | writeAPIError(w, http.StatusNotFound, "mutator not found: "+mutatorId) |
| 62 | return |
| 63 | } |
| 64 | |
| 65 | updated := *existing |
| 66 | // Nil out map fields that must be fully replaced (not merged) by the JSON decode. |
| 67 | updated.Exits = nil |
| 68 | if err := json.NewDecoder(r.Body).Decode(&updated); err != nil { |
| 69 | writeAPIError(w, http.StatusBadRequest, "malformed request body: "+err.Error()) |
| 70 | return |
| 71 | } |
| 72 | |
| 73 | updated.MutatorId = mutatorId |
| 74 | |
| 75 | if err := mutators.SaveMutatorSpec(&updated); err != nil { |
| 76 | writeAPIError(w, http.StatusInternalServerError, err.Error()) |
| 77 | return |
| 78 | } |
| 79 | |
| 80 | writeJSON(w, http.StatusOK, APIResponse[*mutators.MutatorSpec]{ |
| 81 | Success: true, |
| 82 | Data: &updated, |
| 83 | }) |
| 84 | } |
| 85 | |
| 86 | // DELETE /admin/api/v1/mutators/{mutatorId} |
| 87 | func apiV1DeleteMutator(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected