1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package thirdparty
- import (
- "gd_management/common.in/config"
- "gd_management/common.in/utils"
- "go.uber.org/zap"
- "io/ioutil"
- "net/http"
- "time"
- )
- func ZhihHttpGet(api string, data map[string]string) (result []byte, err error) {
- //fullApi := che300FullURL(api)
- 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["User"] = config.Conf.ThirdPart.ZhUser
- data["Pwd"] = config.Conf.ThirdPart.ZhPwd
- client := &http.Client{}
- client.Timeout = 60 * time.Second
- req, err := http.NewRequest("GET", concatGetURL(api, data), nil)
- if err != nil {
- return nil, err
- }
- req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
- resp, err := client.Do(req)
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
- result, err = ioutil.ReadAll(resp.Body)
- return
- }
|