(_ http.ResponseWriter, r *http.Request)
| 8 | ) |
| 9 | |
| 10 | func (api *API) getWorkflows(_ http.ResponseWriter, r *http.Request) Response { |
| 11 | hash, err := api.LatestConfigHash() |
| 12 | if err != nil { |
| 13 | return Response{ |
| 14 | Status: http.StatusInternalServerError, |
| 15 | Error: err.Error(), |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | rows, err := api.db.Query("SELECT id, text FROM workflows WHERE config_hash = $1", hash) |
| 20 | if err != nil { |
| 21 | return Response{ |
| 22 | Status: http.StatusInternalServerError, |
| 23 | Error: err.Error(), |
| 24 | } |
| 25 | } |
| 26 | defer rows.Close() |
| 27 | workflows := map[string]config.Workflow{} |
| 28 | for rows.Next() { |
| 29 | id, text := "", "" |
| 30 | err = rows.Scan(&id, &text) |
| 31 | if err != nil { |
| 32 | return Response{ |
| 33 | Status: http.StatusInternalServerError, |
| 34 | Error: err.Error(), |
| 35 | } |
| 36 | } |
| 37 | workflow := config.Workflow{} |
| 38 | err = workflow.Parse([]byte(text)) |
| 39 | if err != nil { |
| 40 | return Response{ |
| 41 | Status: http.StatusInternalServerError, |
| 42 | Error: err.Error(), |
| 43 | } |
| 44 | } |
| 45 | workflows[id] = workflow |
| 46 | } |
| 47 | return Response{ |
| 48 | Response: workflows, |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func (api *API) getWorkflow(_ http.ResponseWriter, r *http.Request) Response { |
| 53 | vars := mux.Vars(r) |
nothing calls this directly
no test coverage detected