MCPcopy Create free account
hub / github.com/amp-labs/connectors / httpPutCSV

Method httpPutCSV

common/csv.go:38–71  ·  view source on GitHub ↗
(ctx context.Context, url string,
	headers []Header, body []byte,
)

Source from the content-addressed store, hash-verified

36}
37
38func (j *JSONHTTPClient) httpPutCSV(ctx context.Context, url string,
39 headers []Header, body []byte,
40) (*http.Response, []byte, error) {
41 req, err := makeTextCSVPutRequest(ctx, url, headers, body)
42 if err != nil {
43 return nil, nil, err
44 }
45
46 correlationId := uuid.Must(uuid.NewRandom()).String()
47
48 if logging.IsVerboseLogging(ctx) {
49 logRequestWithBody(logging.VerboseLogger(ctx), req, "PUT", correlationId, url, body)
50 } else {
51 logRequestWithoutBody(logging.Logger(ctx), req, "PUT", correlationId, url)
52 }
53
54 rsp, body, err := j.HTTPClient.sendRequest(req)
55
56 if logging.IsVerboseLogging(ctx) {
57 logResponseWithBody(logging.VerboseLogger(ctx), rsp, "PUT", correlationId, url, body)
58 } else {
59 logResponseWithoutBody(logging.Logger(ctx), rsp, "PUT", correlationId, url)
60 }
61
62 if err != nil {
63 logging.Logger(ctx).Error("HTTP request failed",
64 "method", "PUT", "url", url,
65 "correlationId", correlationId, "error", err)
66
67 return nil, nil, err
68 }
69
70 return rsp, body, nil
71}
72
73func makeTextCSVPutRequest(ctx context.Context, url string, headers []Header, body []byte) (*http.Request, error) {
74 req, err := http.NewRequestWithContext(ctx, http.MethodPut, url, bytes.NewReader(body))

Callers 1

PutCSVMethod · 0.95

Calls 11

IsVerboseLoggingFunction · 0.92
VerboseLoggerFunction · 0.92
LoggerFunction · 0.92
makeTextCSVPutRequestFunction · 0.85
logRequestWithBodyFunction · 0.85
logRequestWithoutBodyFunction · 0.85
logResponseWithBodyFunction · 0.85
logResponseWithoutBodyFunction · 0.85
sendRequestMethod · 0.80
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected