)
// SendPostJSONMsg is for sending JSON body
-func SendPostJSONMsg(targetURL string, pbytes []byte) {
+func SendPostJSONMsg(targetURL string, pbytes []byte) (err error) {
buff := bytes.NewBuffer(pbytes)
req, err := http.NewRequest("POST", targetURL, buff)
if err != nil {
- panic(err)
+ return
}
// Content-Type Header
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
- panic(err)
+ return
}
defer resp.Body.Close()
str := string(respBody)
println(str)
}
+ return
}