- 授权协议: 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")
Clean Architecture
Robert C. Martin / Prentice Hall / 2017-9-20 / USD 34.99
Practical Software Architecture Solutions from the Legendary Robert C. Martin (“Uncle Bob”) By applying universal rules of software architecture, you can dramatically improve developer producti......一起来看看 《Clean Architecture》 这本书的介绍吧!
图片转BASE64编码
在线图片转Base64编码工具
RGB CMYK 转换工具
RGB CMYK 互转工具