PostJSON posts json object to url
(url string, obj interface{}, client *http.Client)
| 81 | |
| 82 | // PostJSON posts json object to url |
| 83 | func 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 |
| 95 | func GetJSON(url string, obj interface{}, client *http.Client) (*http.Response, error) { |