// GET /flows func Flows(ctx *Context) { flows, err := models.ListFlows() if err != nil { ctx.Handle(500, "Fail to list flows: %v", err) return } apiFlows := make([]*api.Flow, len(flows)) for i := range flows { apiFlows[i] = &api.Flow{ UUID: flows[i].UUID, Name: flows[i].Name, Pipelines: utils.MapToStrings(flows[i].Pipelines), Created: flows[i].Created, } } ctx.JSON(200, apiFlows) }
// GET /pipelines func Pipelines(ctx *Context) { pipes, err := models.ListPipelines() if err != nil { ctx.Handle(500, "Fail to list pipelines: %v", err) return } apiPipes := make([]*api.Pipeline, len(pipes)) for i := range pipes { apiPipes[i] = &api.Pipeline{ UUID: pipes[i].UUID, Name: pipes[i].Name, Requires: utils.MapToStrings(pipes[i].Requires), Created: pipes[i].Created, } } ctx.JSON(200, apiPipes) }