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

Function apiV1DeleteColorPattern

internal/web/api_v1_colorpatterns.go:77–94  ·  view source on GitHub ↗

DELETE /admin/api/v1/colorpatterns Body: {"name": "patternName"}

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

Source from the content-addressed store, hash-verified

75// DELETE /admin/api/v1/colorpatterns
76// Body: {"name": "patternName"}
77func apiV1DeleteColorPattern(w http.ResponseWriter, r *http.Request) {
78 var body struct {
79 Name string `json:"name"`
80 }
81 if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
82 writeAPIError(w, http.StatusBadRequest, "malformed request body: "+err.Error())
83 return
84 }
85 if body.Name == "" {
86 writeAPIError(w, http.StatusBadRequest, "name is required")
87 return
88 }
89 if err := colorpatterns.DeleteColorPattern(body.Name); err != nil {
90 writeAPIError(w, http.StatusInternalServerError, err.Error())
91 return
92 }
93 writeJSON(w, http.StatusOK, APIResponse[struct{}]{Success: true})
94}

Callers

nothing calls this directly

Calls 3

DeleteColorPatternFunction · 0.92
writeAPIErrorFunction · 0.85
writeJSONFunction · 0.85

Tested by

no test coverage detected