| Crates.io | rumbo_http_client |
| lib.rs | rumbo_http_client |
| version | 0.1.0 |
| created_at | 2025-06-16 04:15:04.168841+00 |
| updated_at | 2025-06-16 04:15:04.168841+00 |
| description | A minimal HTTP client library for basic requests |
| homepage | |
| repository | https://github.com/crisandolindesmanrumahorbo/rumbo_http_client |
| max_upload_size | |
| id | 1713902 |
| size | 38,158 |
A lightweight, minimal HTTP client library for Rust with async support.
Add this to your Cargo.toml:
[dependencies]
rumbo_http_client = "0.1.0"
# Enable TLS support for HTTPS requests
rumbo_http_client = { version = "0.1.0", features = ["tls"] }
use rumbo_http_client::{HttpClient, HttpMethod};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// GET request
let response = HttpClient::fetch(
HttpMethod::GET,
"http://httpbin.org/get".to_string(),
None::<()>,
).await?;
println!("Status: {}", response.status);
if let Some(body) = response.body {
println!("Body: {}", body);
}
// POST request with JSON
let data = json!({"key": "value"});
let response = HttpClient::fetch(
HttpMethod::POST,
"http://httpbin.org/post".to_string(),
Some(data),
).await?;
Ok(())
}
pub async fn fetch<T: Serialize>(
method: HttpMethod,
url: String,
body: Option<T>
) -> Result<Response, HttpError>
pub struct Response {
pub status: u16,
pub headers: HashMap<String, String>,
pub body: Option<String>,
}
impl Response {
pub fn is_success(&self) -> bool
pub fn header(&self, name: &str) -> Option<&String>
}
tls: Enable HTTPS support using native-tlsThis library is optimized for minimal size:
Cargo.tomlRun the example:
cargo run --example basic_usage --features tls
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Contributions are welcome! Please feel free to submit a Pull Request.