1 发送get请求
func http_get(url string) string {
resp, err := http.Get(url)
if err != nil {
fmt.Println(err)
return ""
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
// resp.StatusCode
return string(body)[......]
Tag Archives: HTTP
如何从Shell中快速获得出口IP
通过DNS协议(UDP)
dig +short myip.opendns.com @resolver4.opendns.com
通过HTTP服务(TCP)
curl -s http://whatismyip.akamai.com/
[......]
Go实现http post form表单
go http post form(表单)
resp, err := http.PostForm("https://xxx.com/xxx", url.Values{
"x1": {"xxxxxx"},
"x2": {strings.Join(aa, ",")},
"x3": {content}})
if err != nil {
fmt.Println("phoneAlarm request error")
}
defer resp.Body.Clo[......]
go实现企业微信机器人消息(原生库)
func weworkAlarm(text string, mentionAll bool) {
mentionAllStr := ""
if mentionAll {
mentionAllStr = "@all"
}
dataJsonStr := fmt.Sprintf(`{"msgtype": "text", "text": {"content": "%s", "mentioned_list": [%s]}}`, text, mentionAllStr)[......]
Retrofit 2 关于HTTP返回码的一点小坑
在Retrofit 1 时,会在onError中返回并抛出HttpException,但是在2中,不会再回调onError了,而是会在onNext中,这个任务就需要客户端自己处理。
https://futurestud.io/tutorials/retrofit-2-simple-error-handling
参考如下:
Error Handler in Action
etrofit 2 has a different concept of handling "succe[......]