1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package thirdparty
- import (
- "gd_management/common.in/config"
- "gd_management/common.in/utils"
- "go.uber.org/zap"
- "io/ioutil"
- "net/http"
- "time"
- )
- func CxyHttpGet(api string, data map[string]string) (result []byte, err error) {
- defer func() {
- l.Info("thirdparty",
- zap.String("api", api),
- zap.String("request", utils.MarshalJsonString(data)),
- zap.String("response", utils.MarshalJsonString(result)))
- }()
- if data == nil {
- data = make(map[string]string)
- }
- /*data["userid"] = "yiborantest"
- data["userpwd"] = "EC26E0A72785474884D04EC4ADA8837B"
- */
- data["userid"] = config.Conf.ThirdPart.CxyUserName
- data["userpwd"] = config.Conf.ThirdPart.CxyUserPasswd
- client := &http.Client{}
- client.Timeout = 60 * time.Second
- req, err := http.NewRequest("GET", concatGetURL(api, data), nil)
- if err != nil {
- return nil, err
- }
- resp, err := client.Do(req)
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
- result, err = ioutil.ReadAll(resp.Body)
- return
- }
|