- 授权协议: MIT
- 开发语言: Google Go
- 操作系统: 跨平台
- 软件首页: https://github.com/mozillazg/request
- 软件文档: https://godoc.org/github.com/mozillazg/request
软件介绍
Go-Request 是 HTTP 客户端请求包,灵感来源于 Python Requests。
安装
go get -u github.com/mozillazg/request
文档
API 文档:https://godoc.org/github.com/mozillazg/request
使用
import ( "github.com/mozillazg/request" )
GET:
c := new(http.Client)
req := request.NewRequest(c)
resp, err := req.Get("http://httpbin.org/get")
j, err := resp.Json()
defer resp.Body.Close() // Don't forget close the response body
POST:
req.Data = map[string]string{
"key": "value",
"a": "123",
}
resp, err := req.Post("http://httpbin.org/post")
Cookies:
req.Cookies = map[string]string{
"key": "value",
"a": "123",
}
resp, err := req.Get("http://httpbin.org/cookies")
Headers:
req.Headers = map[string]string{
"Accept-Encoding": "gzip,deflate,sdch",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
}
resp, err := req.Get("http://httpbin.org/get")
Files:
f, err := os.Open("test.txt")
req.Files = []request.FileField{
request.FileField{"file", "test.txt", f},
}resp, err := req.Post("http://httpbin.org/post")
Json:
req.Json = map[string]string{ "a": "A", "b": "B",
}resp, err := req.Post("http://httpbin.org/post")
req.Json = []int{1, 2, 3}
resp, err = req.Post("http://httpbin.org/post")
Proxy:
req.Proxy = "http://127.0.0.1:8080"
// req.Proxy = "https://127.0.0.1:8080"
// req.Proxy = "socks5://127.0.0.1:57341"
resp, err := req.Get("http://httpbin.org/get")
or https://github.com/mozillazg/request/tree/develop/_example/proxy
HTTP Basic Authentication:
req.BasicAuth = request.BasicAuth{"user", "passwd"}
resp, err := req.Get("http://httpbin.org/basic-auth/user/passwd")
程序员2010精华本
程序员杂志社 / 电子工业 / 2011-1 / 49.00元
《程序员(2010精华本)》主要内容:《程序员》创刊10年来,每年末编辑部精心打造的“合订本”已经形成一个品牌,得到广大读者的认可和喜爱。今年,《程序员》杂志内容再次进行了优化整合,除了每期推出的一个大型专题策划,各版块也纷纷以专题、策划的形式,将每月的重点进行了整合,让内容非常具有凝聚力,如专题篇、人物篇、实践篇等。另外杂志的版式、色彩方面也有了很大的飞跃,给读者带来耳目一新的阅读体验。一起来看看 《程序员2010精华本》 这本书的介绍吧!
