Get retrieves a single workflow
(c *gin.Context)
| 177 | |
| 178 | // Get retrieves a single workflow |
| 179 | func (h *WorkflowHandler) Get(c *gin.Context) { |
| 180 | ctx := c.Request.Context() |
| 181 | id := c.Param("id") |
| 182 | |
| 183 | var workflow WorkflowRecord |
| 184 | if err := (*h.store).Get(ctx, "workflows", id, &workflow); err != nil { |
| 185 | if errors.Is(err, store.ErrNotFound) { |
| 186 | c.JSON(http.StatusNotFound, gin.H{ |
| 187 | "success": false, |
| 188 | "error": gin.H{ |
| 189 | "code": "not_found", |
| 190 | "message": "Workflow not found", |
| 191 | }, |
| 192 | }) |
| 193 | return |
| 194 | } |
| 195 | c.JSON(http.StatusInternalServerError, gin.H{ |
| 196 | "success": false, |
| 197 | "error": gin.H{ |
| 198 | "code": "internal_error", |
| 199 | "message": "Failed to get workflow: " + err.Error(), |
| 200 | }, |
| 201 | }) |
| 202 | return |
| 203 | } |
| 204 | |
| 205 | c.JSON(http.StatusOK, gin.H{ |
| 206 | "success": true, |
| 207 | "data": &workflow, |
| 208 | }) |
| 209 | } |
| 210 | |
| 211 | // Update updates a workflow |
| 212 | func (h *WorkflowHandler) Update(c *gin.Context) { |