Expand description
HTTP 客户端模块
提供灵活的 HTTP 请求构建和响应处理能力。
§主要组件
HttpClient:HTTP 客户端核心RequestBuilder:请求构建器Response:响应处理
§示例
ⓘ
use yang_base::http::HttpClient;
// 初始化全局 HTTP 客户端
HttpClient::init_global(30)?;
// 发起 GET 请求
let response = HttpClient::global()?
.get("https://api.example.com/users")
.bearer_token("your_token")
.send()
.await?;
// 解析 JSON 响应
let users: Vec<User> = response.json().await?;Structs§
- Circuit
Breaker - 按 host 分键的熔断器。
clone()共享同一份状态(内部Arc)。 - Circuit
Breaker Config - 熔断器策略配置。默认关闭——只有在
HttpClientConfig中显式设置circuit_breaker: Some(..)才启用。 - Http
Client - HTTP 客户端
- Http
Client Config - HTTP 客户端配置
- Request
Builder - HTTP 请求构建器
- Response
- HTTP 响应
- Retry
Config - 请求级重试策略配置(L-4)。