MCPcopy Create free account
hub / github.com/jetify-com/devbox / clientRequest

Function clientRequest

internal/services/client.go:116–144  ·  view source on GitHub ↗
(path, method, projectDir string)

Source from the content-addressed store, hash-verified

114}
115
116func 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}

Callers 4

StartServicesFunction · 0.85
StopServicesFunction · 0.85
RestartServicesFunction · 0.85
ListServicesFunction · 0.85

Calls 4

GetProcessManagerPortFunction · 0.85
ErrorMethod · 0.45
DoMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected