MCPcopy Create free account
hub / github.com/astercloud/aster / Get

Method Get

server/handlers/tool.go:137–167  ·  view source on GitHub ↗

Get retrieves a single tool

(c *gin.Context)

Source from the content-addressed store, hash-verified

135
136// Get retrieves a single tool
137func (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
170func (h *ToolHandler) Update(c *gin.Context) {

Callers

nothing calls this directly

Calls 4

JSONMethod · 0.80
ContextMethod · 0.65
GetMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected