| Crates.io | client-util |
| lib.rs | client-util |
| version | 0.3.0 |
| created_at | 2024-06-30 07:31:49.446709+00 |
| updated_at | 2025-09-15 11:11:18.96426+00 |
| description | Help you to build requests and handle responses by several extension trait! |
| homepage | |
| repository | https://github.com/4t145/client-util |
| max_upload_size | |
| id | 1287819 |
| size | 134,501 |
Help you to build requests and handle responses by several extension trait!
cargo add client-util
use client_util::prelude::*;
#[tokio::main]
async fn main() -> client_util::Result<()> {
let mut client = build_https_client().expect("fail to build client");
let request = RequestBuilder::get("https://httpbin.org/json")?
.version(http::Version::HTTP_11)
.json("hello client-util")?;
let (parts, response) = request
.send(&mut client)
.await?
.json::<serde_json::Value>()
.await?
.into_parts();
println!("{:?}", parts);
println!("{:?}", response);
Ok(())
}
In RequestExt trait, we send the request by a tower service, so you can add any middle layer on the top of the existed client.
Theoretically, you can add any feature to any client by using tower.
You can find those features in tower-http crate as tower layers.
We have tower-cookie
| flag | description |
|---|---|
| json | json body |
| form | form body |
| multipart | multipart form body |
| query | serialize into and append url's query |
| auth | method to append auth header |
| hyper-client | shortcut to create a hyper http client |
| hyper-client-rustls | hyper-client with rustls |