MCPcopy
hub / github.com/canopy-network/canopy / postRawJSON

Function postRawJSON

plugin/go/tutorial/rpc_test.go:524–541  ·  view source on GitHub ↗

HTTP helper function

(url string, jsonBody string)

Source from the content-addressed store, hash-verified

522
523// HTTP helper function
524func postRawJSON(url string, jsonBody string) ([]byte, error) {
525 resp, err := http.Post(url, "application/json", bytes.NewBufferString(jsonBody))
526 if err != nil {
527 return nil, err
528 }
529 defer resp.Body.Close()
530
531 respBody, err := io.ReadAll(resp.Body)
532 if err != nil {
533 return nil, err
534 }
535
536 if resp.StatusCode >= 400 {
537 return nil, fmt.Errorf("HTTP %d: %s", resp.StatusCode, string(respBody))
538 }
539
540 return respBody, nil
541}

Callers 7

keystoreNewKeyFunction · 0.70
keystoreGetKeyFunction · 0.70
getHeightFunction · 0.70
getAccountBalanceFunction · 0.70
waitForTxInclusionFunction · 0.70
checkTxNotFailedFunction · 0.70
buildSignAndSendTxFunction · 0.70

Calls 2

CloseMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected