Add error return logic in SendPostMsg
authorjw_wonny.cha <jw_wonny.cha@samsung.com>
Mon, 25 Mar 2019 08:01:00 +0000 (17:01 +0900)
committerjw_wonny.cha <jw_wonny.cha@samsung.com>
Mon, 25 Mar 2019 08:01:00 +0000 (17:01 +0900)
src/servicemgr/http_sender.go

index 3c85e13..821f667 100644 (file)
@@ -7,12 +7,12 @@ import (
 )
 
 // 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
@@ -21,7 +21,7 @@ func SendPostJSONMsg(targetURL string, pbytes []byte) {
        client := &http.Client{}
        resp, err := client.Do(req)
        if err != nil {
-               panic(err)
+               return
        }
        defer resp.Body.Close()
 
@@ -31,4 +31,5 @@ func SendPostJSONMsg(targetURL string, pbytes []byte) {
                str := string(respBody)
                println(str)
        }
+       return
 }