Get retrieves a single tool
(c *gin.Context)
| 135 | |
| 136 | // Get retrieves a single tool |
| 137 | func (h *ToolHandler) Get(c *gin.Context) { |
| 138 | ctx := c.Request.Context() |
| 139 | id := c.Param("id") |
| 140 | |
| 141 | var tool ToolRecord |
| 142 | if err := (*h.store).Get(ctx, "tools", id, &tool); err != nil { |
| 143 | if errors.Is(err, store.ErrNotFound) { |
| 144 | c.JSON(http.StatusNotFound, gin.H{ |
| 145 | "success": false, |
| 146 | "error": gin.H{ |
| 147 | "code": "not_found", |
| 148 | "message": "Tool not found", |
| 149 | }, |
| 150 | }) |
| 151 | return |
| 152 | } |
| 153 | c.JSON(http.StatusInternalServerError, gin.H{ |
| 154 | "success": false, |
| 155 | "error": gin.H{ |
| 156 | "code": "internal_error", |
| 157 | "message": err.Error(), |
| 158 | }, |
| 159 | }) |
| 160 | return |
| 161 | } |
| 162 | |
| 163 | c.JSON(http.StatusOK, gin.H{ |
| 164 | "success": true, |
| 165 | "data": &tool, |
| 166 | }) |
| 167 | } |
| 168 | |
| 169 | // Update updates a tool |
| 170 | func (h *ToolHandler) Update(c *gin.Context) { |