Skip to main content

yang_base/http/
mod.rs

1//! HTTP 客户端模块
2//!
3//! 提供灵活的 HTTP 请求构建和响应处理能力。
4//!
5//! # 主要组件
6//!
7//! - `HttpClient`:HTTP 客户端核心
8//! - `RequestBuilder`:请求构建器
9//! - `Response`:响应处理
10//!
11//! # 示例
12//!
13//! ```rust,ignore
14//! use yang_base::http::HttpClient;
15//!
16//! // 初始化全局 HTTP 客户端
17//! HttpClient::init_global(30)?;
18//!
19//! // 发起 GET 请求
20//! let response = HttpClient::global()?
21//!     .get("https://api.example.com/users")
22//!     .bearer_token("your_token")
23//!     .send()
24//!     .await?;
25//!
26//! // 解析 JSON 响应
27//! let users: Vec<User> = response.json().await?;
28//! ```
29
30mod circuit_breaker;
31mod client;
32mod request;
33mod response;
34
35pub use circuit_breaker::{CircuitBreaker, CircuitBreakerConfig};
36pub use client::{HttpClient, HttpClientConfig};
37pub use request::{RequestBuilder, RetryConfig};
38pub use response::Response;
39
40#[cfg(test)]
41mod __tests__;