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)
| 1182 | // do executes the given request and returns the response. It creates an |
| 1183 | // opentracing span to track the length of the request. |
| 1184 | func (a *API) do(ctx context.Context, req *http.Request, spanName string) (*http.Response, error) { |
| 1185 | // TODO(adonovan): use NewRequestWithContext(ctx) and drop ctx parameter. |
| 1186 | span, ctx := opentracing.StartSpanFromContext(ctx, spanName) |
| 1187 | defer span.Finish() |
| 1188 | req = req.WithContext(ctx) |
| 1189 | |
| 1190 | httpClient, err := a.client() |
| 1191 | if err != nil { |
| 1192 | return nil, err |
| 1193 | } |
| 1194 | |
| 1195 | return httpClient.Do(req) |
| 1196 | } |
| 1197 | |
| 1198 | // setHeaders sets the required headers for the API. |
| 1199 | func (a *API) setHeaders(req *http.Request) { |
no test coverage detected