| Crates.io | deboa |
| lib.rs | deboa |
| version | 0.0.9 |
| created_at | 2025-02-13 13:45:14.58988+00 |
| updated_at | 2025-12-09 18:32:31.350159+00 |
| description | A friendly rest client on top of hyper. |
| homepage | https://github.com/ararog/deboa |
| repository | https://github.com/ararog/deboa |
| max_upload_size | |
| id | 1554229 |
| size | 296,454 |
deboa ("I'm ok" in portuguese) is a straightforward, non opinionated, developer-centric HTTP client library for Rust. It offers a rich array of modern features—from flexible authentication and serialization formats to runtime compatibility and middleware support—while maintaining simplicity and ease of use. It’s especially well-suited for Rust projects that require a lightweight, efficient HTTP client without sacrificing control or extensibility.
This release has a major api change. Please check the migration guide for more information.
deboa = { version = "0.0.7", features = ["http1", "tokio-rt"] }
http = "1.3.1"
use deboa::{
Deboa, Result, request::{DeboaRequest, FetchWith, get}
};
use deboa_extras::http::{self, serde::json::JsonBody};
use ::http::Method;
#[derive(Debug, serde::Deserialize)]
pub struct Post {
pub id: u64,
pub title: String,
pub body: String,
}
#[tokio::main]
async fn main() -> Result<()> {
let mut client = Deboa::new();
/*
// You can also use the Fetch trait to issue requests
let posts: Vec<Post> = "https://jsonplaceholder.typicode.com/posts"
.fetch_with(client)
.await?
.body_as(JsonBody)
.await?;
// or use at, from (defaults to GET) and to (defaults to POST) methods:
let posts: Vec<Post> = DeboaRequest::at("https://jsonplaceholder.typicode.com/posts", Method::GET)?
.send_with(client)
.await?
.body_as(JsonBody)
.await?;
// shifleft? Yes sir! Defaults to GET, but you can change it, same for headers.
let request = &client << "https://jsonplaceholder.typicode.com/posts";
let posts: Vec<Post> = client.execute(request)
.await?
.body_as(JsonBody)
.await?;
// or simply:
let posts: Vec<Post> = client
.execute("https://jsonplaceholder.typicode.com/posts")
.await?
.body_as(JsonBody)
.await?;
// you can also post a json body
let body = serde_json::json!({
"id": 100,
"title": "Some title",
"body": "Some body"
});
let request = post("https://jsonplaceholder.typicode.com/posts")?
.header(header::CONTENT_TYPE, "application/json")
.body_as(JsonBody, body)?;
let response = request.send_with(&mut client).await?;
assert_eq!(response.status(), 201);
*/
let posts: Vec<Post> = get("https://jsonplaceholder.typicode.com/posts")?
.send_with(client)
.await?
.body_as(JsonBody)
.await?;
println!("posts: {:#?}", posts);
Ok(())
}
MIT
Rogerio Pereira Araujo rogerio.araujo@gmail.com