MCPcopy
hub / github.com/tuna/tunasync / PostJSON

Function PostJSON

internal/util.go:83–92  ·  view source on GitHub ↗

PostJSON posts json object to url

(url string, obj interface{}, client *http.Client)

Source from the content-addressed store, hash-verified

81
82// PostJSON posts json object to url
83func PostJSON(url string, obj interface{}, client *http.Client) (*http.Response, error) {
84 if client == nil {
85 client, _ = CreateHTTPClient("")
86 }
87 b := new(bytes.Buffer)
88 if err := json.NewEncoder(b).Encode(obj); err != nil {
89 return nil, err
90 }
91 return client.Post(url, "application/json; charset=utf-8", b)
92}
93
94// GetJSON gets a json response from url
95func GetJSON(url string, obj interface{}, client *http.Client) (*http.Response, error) {

Callers 6

sendCommandToWorkerFunction · 0.85
registerWorkerMethod · 0.85
updateStatusMethod · 0.85
updateSchedInfoMethod · 0.85
handleClientCmdMethod · 0.85
TestHTTPServerFunction · 0.85

Calls 1

CreateHTTPClientFunction · 0.85

Tested by 2

sendCommandToWorkerFunction · 0.68
TestHTTPServerFunction · 0.68