MCPcopy Create free account
hub / github.com/crossjoin-io/crossjoin / getWorkflows

Method getWorkflows

api/api_workflows.go:10–50  ·  view source on GitHub ↗
(_ http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

8)
9
10func (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
52func (api *API) getWorkflow(_ http.ResponseWriter, r *http.Request) Response {
53 vars := mux.Vars(r)

Callers

nothing calls this directly

Calls 2

LatestConfigHashMethod · 0.95
ParseMethod · 0.95

Tested by

no test coverage detected