golem_wasi_http/lib.rs
1#![deny(missing_docs)]
2#![deny(missing_debug_implementations)]
3#![cfg_attr(docsrs, feature(doc_cfg))]
4#![cfg_attr(test, deny(warnings))]
5
6//! # golem-wasi-http
7//!
8//! An HTTP client library that uses WASI HTTP (WebAssembly System Interface) as its backend.
9//!
10//! The library provides a convenient API for making HTTP requests from WASM components.
11//! It supports both async and synchronous operations, with optional support for JSON and multipart forms.
12//!
13//! Originally started as a fork of the [reqwest](https://crates.io/crates/reqwest) library but diverged significantly
14//! and dropped all the non WASI-HTTP backends.
15//!
16//! ## Features
17//!
18//! - Async and blocking Clients
19//! - Plain bodies, JSON, form data, and multipart support
20//! - Custom request/response body handling
21//!
22//! ## Optional Features
23//!
24//! The following are a list of [Cargo features][cargo-features] that can be
25//! enabled or disabled:
26//!
27//! - **async**: Async client API using the [wstd](https://crates.io/crates/wstd) crate
28//! - **json**: Provides serialization and deserialization for JSON bodies.
29//! - **multipart**: Provides functionality for multipart forms.
30//!
31
32pub use http::header;
33pub use http::Method;
34pub use http::{StatusCode, Version};
35pub use url::Url;
36
37// universal mods
38#[macro_use]
39mod error;
40mod into_url;
41mod response;
42
43pub use self::error::{Error, Result};
44pub use self::into_url::IntoUrl;
45pub use self::response::ResponseBuilderExt;
46
47mod util;
48mod wasi;
49
50pub use self::wasi::{Body, Client, ClientBuilder, Request, RequestBuilder, Response};
51pub use ::wasi::http::types::IncomingBody;
52pub use ::wasi::io::streams::{InputStream, StreamError};
53
54#[cfg(feature = "multipart")]
55pub use self::wasi::multipart;
56
57#[cfg(feature = "async")]
58pub use crate::wasi::{CustomRequestBodyWriter, CustomRequestExecution};