(url string, reqJson []byte, respStruct interface{})
| 80 | } |
| 81 | |
| 82 | func InvokePostApiWithJson(url string, reqJson []byte, respStruct interface{}) error { |
| 83 | resp, err := http.Post(url, "application/json", bytes.NewReader(reqJson)) |
| 84 | if err != nil { |
| 85 | return fmt.Errorf("invoke nomad api failed, error: %v", err) |
| 86 | } |
| 87 | defer resp.Body.Close() |
| 88 | if err := handleNomadResponse(resp.Body, resp.StatusCode, &respStruct); nil != err { |
| 89 | return fmt.Errorf("response contains error: %v", err) |
| 90 | } |
| 91 | return nil |
| 92 | } |
| 93 | |
| 94 | func InvokeHttpUrlWithBody(method, url string, body []byte, respStruct interface{}) error { |
| 95 | req, err := http.NewRequest(method, url, bytes.NewReader(body)) |
no test coverage detected