github.com/qiniu/go-sdk/v7@v7.27.0/client/doc.go (about) 1 // Package client 提供七牛云 API 的底层 HTTP 客户端。 2 // 3 // [Client] 封装了标准库 [net/http.Client],自动处理 User-Agent 设置、 4 // 请求 ID 注入(X-Reqid)、认证签名、JSON/表单序列化和错误解析。 5 // 6 // 高级用户通常使用 storage 或 storagev2 包,不需要直接使用本包。 7 // 8 // # 使用默认客户端 9 // 10 // var ret MyResponse 11 // err := client.DefaultClient.CallWithJson(ctx, &ret, "POST", url, nil, body) 12 // 13 // # 错误处理 14 // 15 // API 错误以 [*ErrorInfo] 返回,包含 HTTP 状态码、错误码和请求 ID: 16 // 17 // err := client.DefaultClient.Call(ctx, &ret, "GET", url, nil) 18 // if e, ok := err.(*client.ErrorInfo); ok { 19 // fmt.Println(e.Code, e.Err, e.Reqid) 20 // } 21 // 22 // # 调试模式 23 // 24 // client.TurnOnDebug() // 输出 HTTP 请求/响应详情 25 // client.DeepDebugInfo = true // 同时输出请求/响应 body 26 // 27 // # DNS 预解析 28 // 29 // 通过 Context 注入预解析的 IP 地址,跳过 DNS 查询: 30 // 31 // ctx = client.WithResolvedIPs(ctx, "up.qiniup.com", []net.IP{ip}) 32 package client