wasi_http_client/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! # wasi-http-client
4//!
5//! `wasi_http_client` is an HTTP client library for [WASI Preview 2](https://github.com/WebAssembly/WASI/tree/main/preview2),
6//! making it easier to send http(s) requests in WASI components.
7//!
8//! ```
9//! # use anyhow::Result;
10//! # use std::time::Duration;
11//! # use wasi_http_client::Client;
12//! # fn run() -> Result<()> {
13//! let resp = Client::new()
14//!     .post("https://httpbin.org/post")
15//!     .connect_timeout(Duration::from_secs(5))
16//!     .send()?;
17//!
18//! println!("status code: {}", resp.status());
19//! # Ok(())
20//! # }
21//! ```
22
23mod client;
24mod request;
25mod response;
26
27pub use self::{client::Client, request::RequestBuilder, response::Response};
28pub use wasi::http::types::Method;