Delete deletes a tool
(c *gin.Context)
| 261 | |
| 262 | // Delete deletes a tool |
| 263 | func (h *ToolHandler) Delete(c *gin.Context) { |
| 264 | ctx := c.Request.Context() |
| 265 | id := c.Param("id") |
| 266 | |
| 267 | if err := (*h.store).Delete(ctx, "tools", id); err != nil { |
| 268 | if errors.Is(err, store.ErrNotFound) { |
| 269 | c.JSON(http.StatusNotFound, gin.H{ |
| 270 | "success": false, |
| 271 | "error": gin.H{ |
| 272 | "code": "not_found", |
| 273 | "message": "Tool not found", |
| 274 | }, |
| 275 | }) |
| 276 | return |
| 277 | } |
| 278 | c.JSON(http.StatusInternalServerError, gin.H{ |
| 279 | "success": false, |
| 280 | "error": gin.H{ |
| 281 | "code": "internal_error", |
| 282 | "message": err.Error(), |
| 283 | }, |
| 284 | }) |
| 285 | return |
| 286 | } |
| 287 | |
| 288 | logging.Info(ctx, "tool.deleted", map[string]any{ |
| 289 | "id": id, |
| 290 | }) |
| 291 | |
| 292 | c.Status(http.StatusNoContent) |
| 293 | } |
| 294 | |
| 295 | // Execute executes a tool |
| 296 | func (h *ToolHandler) Execute(c *gin.Context) { |