List lists all workflows
(c *gin.Context)
| 139 | |
| 140 | // List lists all workflows |
| 141 | func (h *WorkflowHandler) List(c *gin.Context) { |
| 142 | ctx := c.Request.Context() |
| 143 | status := c.Query("status") |
| 144 | |
| 145 | records, err := (*h.store).List(ctx, "workflows") |
| 146 | if err != nil { |
| 147 | c.JSON(http.StatusInternalServerError, gin.H{ |
| 148 | "success": false, |
| 149 | "error": gin.H{ |
| 150 | "code": "internal_error", |
| 151 | "message": "Failed to list workflows: " + err.Error(), |
| 152 | }, |
| 153 | }) |
| 154 | return |
| 155 | } |
| 156 | |
| 157 | workflows := make([]*WorkflowRecord, 0) |
| 158 | for _, record := range records { |
| 159 | var wf WorkflowRecord |
| 160 | if err := store.DecodeValue(record, &wf); err != nil { |
| 161 | continue |
| 162 | } |
| 163 | |
| 164 | // Filter by status |
| 165 | if status != "" && wf.Status != status { |
| 166 | continue |
| 167 | } |
| 168 | |
| 169 | workflows = append(workflows, &wf) |
| 170 | } |
| 171 | |
| 172 | c.JSON(http.StatusOK, gin.H{ |
| 173 | "success": true, |
| 174 | "data": workflows, |
| 175 | }) |
| 176 | } |
| 177 | |
| 178 | // Get retrieves a single workflow |
| 179 | func (h *WorkflowHandler) Get(c *gin.Context) { |