You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
572 B
24 lines
572 B
package dockingorganization
|
|
|
|
import (
|
|
"fmt"
|
|
"hr_server/overall/overallhandle"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func GetUrl(sendUrl string) (respBody []byte, err error) {
|
|
req, err := http.NewRequest("GET", sendUrl, nil)
|
|
|
|
client := &http.Client{Timeout: 500 * time.Second} // 设置请求超时时长5s
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
errmsg := fmt.Sprintf("访问请求[%v] http.DefaultClient.Do() err: %v", sendUrl, err)
|
|
overallhandle.WriteLog("e", errmsg)
|
|
return
|
|
}
|
|
defer resp.Body.Close()
|
|
respBody, err = ioutil.ReadAll(resp.Body)
|
|
return
|
|
}
|
|
|