闲来无事造了个小轮子, 200行代码的http请求库, 纯链式写法, 各位觉得好的话赏个star呗
github
Hasaki
http request library for golang
- install
go get github.com/lxzan/hasaki
- usage
// GET https://api.github.com/
hasaki.
Get("https://api.github.com/").
Json()
// GET http://127.0.0.1:8080/server.php?hello%5B%5D=world&hello%5B%5D=%E8%BF%9E%E7%BB%AD%E6%80%A7&me=lxzan
hasaki.
Get("http://127.0.0.1:8080/server.php").
Send(hasaki.JSON{
"hello": []string{"world", "连续性"},
"me": "lxzan",
}).
Json()
// POST
hasaki.
POST("http://127.0.0.1:9999/").
Set(hasaki.Form{
"X-Access-Token": token,
"X-Running-Env": env,
}).
Json()
有疑问加站长微信联系(非本文作者)