(path, method, projectDir string)
| 114 | } |
| 115 | |
| 116 | func clientRequest(path, method, projectDir string) (string, int, error) { |
| 117 | port, err := GetProcessManagerPort(projectDir) |
| 118 | if err != nil { |
| 119 | err := fmt.Errorf("unable to connect to process-compose server: %s", err.Error()) |
| 120 | return "", 0, err |
| 121 | } |
| 122 | |
| 123 | req, err := http.NewRequest(method, fmt.Sprintf("http://localhost:%d%s", port, path), nil) |
| 124 | if err != nil { |
| 125 | return "", 0, err |
| 126 | } |
| 127 | |
| 128 | client := &http.Client{} |
| 129 | resp, err := client.Do(req) |
| 130 | if err != nil { |
| 131 | return "", 0, err |
| 132 | } |
| 133 | |
| 134 | defer resp.Body.Close() |
| 135 | buf := new(bytes.Buffer) |
| 136 | _, err = buf.ReadFrom(resp.Body) |
| 137 | if err != nil { |
| 138 | return "", 0, err |
| 139 | } |
| 140 | body := buf.String() |
| 141 | status := resp.StatusCode |
| 142 | |
| 143 | return body, status, nil |
| 144 | } |
no test coverage detected