ugi 0.2.1

Runtime-agnostic Rust request client with HTTP/1.1, HTTP/2, HTTP/3, H2C, WebSocket, SSE, and gRPC support
Documentation
use futures_lite::future::block_on;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize)]
struct CreateMessage {
    title: String,
    body: String,
}

#[derive(Debug, Deserialize)]
struct Message {
    id: u64,
    title: String,
    body: String,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    block_on(async move {
        let client = ugi::Client::builder().build()?;
        let payload = CreateMessage {
            title: "hello".to_owned(),
            body: "from request".to_owned(),
        };

        let req = client
            .post("https://api.example.com/messages")
            .header("x-request-id", "demo-001")?
            .json(&payload)?;
        let res = req.await?;
        let message: Message = res.json().await?;

        println!("message#{} {} {}", message.id, message.title, message.body);
        Ok(())
    })
}