MCPcopy
hub / github.com/uber/aresdb / readJSONResponse

Method readJSONResponse

client/schema.go:406–425  ·  view source on GitHub ↗
(response *http.Response, err error, data interface{})

Source from the content-addressed store, hash-verified

404}
405
406func (hf *httpSchemaFetcher) readJSONResponse(response *http.Response, err error, data interface{}) error {
407 if err != nil {
408 return utils.StackError(err, "Failed call remote endpoint")
409 }
410
411 respBytes, err := ioutil.ReadAll(response.Body)
412 if err != nil {
413 return utils.StackError(err, "Failed to read response body")
414 }
415
416 if response.StatusCode != http.StatusOK {
417 return utils.StackError(nil, "Received error response %d:%s from remote endpoint", response.StatusCode, respBytes)
418 }
419
420 err = json.Unmarshal(respBytes, data)
421 if err != nil {
422 return utils.StackError(err, "Failed to unmarshal json")
423 }
424 return nil
425}
426
427func (hf *httpSchemaFetcher) tablePath(tableName string) string {
428 return fmt.Sprintf("%s/%s", hf.listTablesPath(), tableName)

Callers 4

FetchAllEnumsMethod · 0.95
ExtendEnumCasesMethod · 0.95
FetchSchemaMethod · 0.95
FetchAllSchemasMethod · 0.95

Calls 1

StackErrorFunction · 0.92

Tested by

no test coverage detected