纯链式golang http请求库, 支持HTTP代理

闲来无事造了个小轮子, 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()

// Proxy
resp, _ := hasaki.
    Get("https://api.github.com/").
    SetProxy("http://127.0.0.1:8888").
    GetBody()
    原文作者:codebeast
    原文地址: https://segmentfault.com/a/1190000015633388
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞