Delete 删除项目
(w http.ResponseWriter, r *http.Request)
| 254 | |
| 255 | // Delete 删除项目 |
| 256 | func (h *ProjectHandler) Delete(w http.ResponseWriter, r *http.Request) { |
| 257 | if r.Method != http.MethodPost { |
| 258 | http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) |
| 259 | return |
| 260 | } |
| 261 | var req struct { |
| 262 | ID string `json:"id"` |
| 263 | } |
| 264 | if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.ID == "" { |
| 265 | writeJSON(w, http.StatusBadRequest, map[string]string{"error": "id is required"}) |
| 266 | return |
| 267 | } |
| 268 | if err := h.store.Delete(req.ID); err != nil { |
| 269 | writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()}) |
| 270 | return |
| 271 | } |
| 272 | writeJSON(w, http.StatusOK, map[string]string{"status": "deleted"}) |
| 273 | } |
| 274 | |
| 275 | // Cache 查看项目缓存摘要 |
| 276 | func (h *ProjectHandler) Cache(w http.ResponseWriter, r *http.Request) { |