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

Method Get

common/json.go:64–71  ·  view source on GitHub ↗

Get makes a GET request to the given URL and returns the response body as a JSON object. If the response is not a 2xx, an error is returned. If the response is a 401, the caller should refresh the access token and retry the request. If errorHandler is nil, then the default error handler is used. If

(ctx context.Context, url string, headers ...Header)

Source from the content-addressed store, hash-verified

62// refresh the access token and retry the request. If errorHandler is nil, then the default error
63// handler is used. If not, the caller can inject their own error handling logic.
64func (j *JSONHTTPClient) Get(ctx context.Context, url string, headers ...Header) (*JSONHTTPResponse, error) {
65 res, body, err := j.HTTPClient.Get(ctx, url, addAcceptJSONHeader(headers)...) //nolint:bodyclose
66 if err != nil {
67 return nil, j.ErrorPostProcessor.handleError(err)
68 }
69
70 return ParseJSONResponse(ctx, res, body)
71}
72
73// Post makes a POST request to the given URL and returns the response body as a JSON object.
74// ReqBody must be JSON-serializable. If it is not, an error is returned.

Calls 4

addAcceptJSONHeaderFunction · 0.85
ParseJSONResponseFunction · 0.85
handleErrorMethod · 0.80
GetMethod · 0.65