| Crates.io | unistore-http |
| lib.rs | unistore-http |
| version | 0.1.0 |
| created_at | 2026-01-20 01:42:24.293186+00 |
| updated_at | 2026-01-20 01:42:24.293186+00 |
| description | HTTP client capability for UniStore |
| homepage | https://github.com/yangbo1317/unistore |
| repository | https://github.com/yangbo1317/unistore |
| max_upload_size | |
| id | 2055634 |
| size | 102,009 |
UniStore HTTP 客户端能力,基于 reqwest 提供统一的 HTTP 请求接口。
unistore-http 提供:
[dependencies]
unistore-http = "0.1"
use unistore_http::{HttpClient, HttpConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 创建客户端
let client = HttpClient::new()?;
// GET 请求
let response = client.get("https://api.example.com/users")
.header("Authorization", "Bearer token")
.send()
.await?;
// POST JSON
let user = serde_json::json!({"name": "Alice"});
let response = client.post("https://api.example.com/users")
.json(&user)
.send()
.await?;
Ok(())
}
let config = HttpConfig::builder()
.timeout(Duration::from_secs(30))
.max_retries(3)
.user_agent("MyApp/1.0")
.build();
let client = HttpClient::with_config(config)?;
需要直接使用 reqwest 时:
let inner: &reqwest::Client = client.inner();
MIT OR Apache-2.0
本 crate 基于以下优秀项目构建:
感谢这些项目的作者和贡献者们!