do executes the given request and returns the response. It creates an opentracing span to track the length of the request.
(ctx context.Context, req *http.Request, spanName string)
| 1276 | // do executes the given request and returns the response. It creates an |
| 1277 | // opentracing span to track the length of the request. |
| 1278 | func (a *API) do(ctx context.Context, req *http.Request, spanName string) (*http.Response, error) { |
| 1279 | // TODO(adonovan): use NewRequestWithContext(ctx) and drop ctx parameter. |
| 1280 | span, ctx := opentracing.StartSpanFromContext(ctx, spanName) |
| 1281 | defer span.Finish() |
| 1282 | req = req.WithContext(ctx) |
| 1283 | |
| 1284 | httpClient, err := a.client() |
| 1285 | if err != nil { |
| 1286 | return nil, err |
| 1287 | } |
| 1288 | |
| 1289 | return httpClient.Do(req) |
| 1290 | } |
| 1291 | |
| 1292 | // setHeaders sets the required headers for the API. |
| 1293 | func (a *API) setHeaders(req *http.Request) { |
no test coverage detected