|
|
@ -4,6 +4,7 @@ |
|
|
|
package network |
|
|
|
|
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"crypto/md5" |
|
|
|
"encoding/hex" |
|
|
|
"errors" |
|
|
@ -45,6 +46,33 @@ func FnPost(url, param string) ([]byte, error) { |
|
|
|
return body, nil |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* post 请求 |
|
|
|
*/ |
|
|
|
func PostJson(url string, param []byte) ([]byte, error) { |
|
|
|
httpClient := &http.Client{} |
|
|
|
|
|
|
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(param)) |
|
|
|
if err != nil { |
|
|
|
return []byte(""), err |
|
|
|
} |
|
|
|
|
|
|
|
req.Header.Set("Content-Type", "application/json") |
|
|
|
|
|
|
|
resp, err := httpClient.Do(req) |
|
|
|
if err != nil { |
|
|
|
return []byte(""), err |
|
|
|
} |
|
|
|
|
|
|
|
defer resp.Body.Close() |
|
|
|
body, err := ioutil.ReadAll(resp.Body) |
|
|
|
if err != nil { |
|
|
|
return []byte(""), err |
|
|
|
} |
|
|
|
|
|
|
|
return body, nil |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 取本地IP |
|
|
|
*/ |
|
|
|