一个增强的 Go HTTP 客户端
Heimdall 是一个 HTTP 客户端,可帮助您的应用程序大规模地发出大量请求。使用 Heimdall,您可以:
所有 HTTP 方法都以流畅接口的形式暴露。
go get -u github.com/gojek/heimdall/v8此包可通过在您的 .go 文件中添加以下导入语句来使用。
import "github.com/gojek/heimdall/v8/httpclient"GET 请求以下示例将打印谷歌主页的内容:
// Create a new HTTP client with a default timeout
timeout := 1000 * time.Millisecond
client := httpclient.NewClient(httpclient.WithHTTPTimeout(timeout))
// Use the clients GET method to create and execute the request
res, err := client.Get("http://google.com", nil)
if err != nil{
panic(err)
}
// Heimdall returns the standard *http.Response object
body, err := io.ReadAll(res.Body)
fmt.Println(string(body))你也可以使用 `*http.
暂无开放 Issues,或尚未同步最近议题。