Delete deletes a workflow
(c *gin.Context)
| 311 | |
| 312 | // Delete deletes a workflow |
| 313 | func (h *WorkflowHandler) Delete(c *gin.Context) { |
| 314 | ctx := c.Request.Context() |
| 315 | id := c.Param("id") |
| 316 | |
| 317 | if err := (*h.store).Delete(ctx, "workflows", id); err != nil { |
| 318 | if errors.Is(err, store.ErrNotFound) { |
| 319 | c.JSON(http.StatusNotFound, gin.H{ |
| 320 | "success": false, |
| 321 | "error": gin.H{ |
| 322 | "code": "not_found", |
| 323 | "message": "Workflow not found", |
| 324 | }, |
| 325 | }) |
| 326 | return |
| 327 | } |
| 328 | c.JSON(http.StatusInternalServerError, gin.H{ |
| 329 | "success": false, |
| 330 | "error": gin.H{ |
| 331 | "code": "internal_error", |
| 332 | "message": "Failed to delete workflow: " + err.Error(), |
| 333 | }, |
| 334 | }) |
| 335 | return |
| 336 | } |
| 337 | |
| 338 | logging.Info(ctx, "workflow.deleted", map[string]any{ |
| 339 | "id": id, |
| 340 | }) |
| 341 | |
| 342 | c.Status(http.StatusNoContent) |
| 343 | } |
| 344 | |
| 345 | // Execute executes a workflow |
| 346 | func (h *WorkflowHandler) Execute(c *gin.Context) { |