HTTP helper function
(url string, jsonBody string)
| 522 | |
| 523 | // HTTP helper function |
| 524 | func 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 | } |
no test coverage detected