41 stable releases (12 major)

new 21.0.1 May 22, 2024
20.0.2 May 7, 2024
19.0.2 Apr 11, 2024
19.0.0 Mar 20, 2024
9.0.4 Jun 13, 2023

#1138 in WebAssembly

Download history 1153/week @ 2024-02-01 1689/week @ 2024-02-08 1946/week @ 2024-02-15 2347/week @ 2024-02-22 3165/week @ 2024-02-29 4345/week @ 2024-03-07 5045/week @ 2024-03-14 4722/week @ 2024-03-21 5574/week @ 2024-03-28 5226/week @ 2024-04-04 4238/week @ 2024-04-11 6511/week @ 2024-04-18 5084/week @ 2024-04-25 4856/week @ 2024-05-02 5169/week @ 2024-05-09 3413/week @ 2024-05-16

20,381 downloads per month
Used in 15 crates (9 directly)

Apache-2.0 WITH LLVM-exception

3MB
49K SLoC

Wasmtime's WASI HTTP Implementation

This crate's implementation is primarily built on top of hyper.

WASI HTTP Interfaces

This crate contains implementations of the following interfaces:

  • wasi:http/incoming-handler
  • wasi:http/outgoing-handler
  • wasi:http/types

The crate also contains an implementation of the wasi:http/proxy world.

All traits are implemented in terms of a WasiHttpView trait which provides basic access to WasiHttpCtx, configuration for WASI HTTP, and a wasmtime_wasi::ResourceTable, the state for all host-defined component model resources.

Examples

Usage of this crate is done through a few steps to get everything hooked up:

  1. First implement WasiHttpView for your type which is the T in wasmtime::Store<T>.
  2. Add WASI HTTP interfaces to a wasmtime::component::Linker<T>. This is either done through functions like proxy::add_to_linker (which bundles all interfaces in the wasi:http/proxy world together) or through individual interfaces like the bindings::http::outgoing_handler::add_to_linker_get_host function.
  3. Use the previous wasmtime::component::Linker<T>::instantiate to instantiate a wasmtime::component::Component within a wasmtime::Store<T>. If you're targeting the wasi:http/proxy world, you can instantiate the component with proxy::Proxy::instantiate_async or proxy::sync::Proxy::instantiate functions.

Dependencies

~27–41MB
~806K SLoC