MCPcopy
hub / github.com/harness/harness / do

Method do

client/client.go:171–190  ·  view source on GitHub ↗

helper function to make an http request.

(ctx context.Context, rawurl, method string, noToken bool, in, out interface{})

Source from the content-addressed store, hash-verified

169
170// helper function to make an http request.
171func (c *HTTPClient) do(ctx context.Context, rawurl, method string, noToken bool, in, out interface{}) error {
172 // executes the http request and returns the body as
173 // and io.ReadCloser
174 body, err := c.stream(ctx, rawurl, method, noToken, in, out)
175 if body != nil {
176 defer func(body io.ReadCloser) {
177 _ = body.Close()
178 }(body)
179 }
180 if err != nil {
181 return err
182 }
183
184 // if a json response is expected, parse and return
185 // the json response.
186 if out != nil {
187 return json.NewDecoder(body).Decode(out)
188 }
189 return nil
190}
191
192// helper function to stream a http request.
193func (c *HTTPClient) stream(ctx context.Context, rawurl, method string, noToken bool,

Callers 4

getMethod · 0.95
postMethod · 0.95
patchMethod · 0.95
deleteMethod · 0.95

Calls 3

streamMethod · 0.95
CloseMethod · 0.65
DecodeMethod · 0.65

Tested by

no test coverage detected