http

package
v0.0.0-...-e5591e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package http 提供基础 http 客户端组件

本包通过替换 http.DefaultTransport 实现以下功能: - 日志(logging) - 链路追踪(tracing) - 指标监控(metrics)

请务必使用 http.NewRequestWithContext 构造 req 对象,这样才能传递 ctx 信息。

如果希望使用自定义 Transport,需要将 RoundTrip 的逻辑 最终委托给 http.DefaultTransport

使用示例:

req, _ := http.NewRequestWithContext(ctx, method, url, body)
c := &http.Client{
	Timeout: 1 * time.Second,
}
resp, err := c.Do(req)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL