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:
- First implement [
WasiHttpView
] for your type which is theT
in [wasmtime::Store<T>
]. - 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 thewasi:http/proxy
world together) or through individual interfaces like the [bindings::http::outgoing_handler::add_to_linker_get_host
] function. - Use the previous [
wasmtime::component::Linker<T>::instantiate
] to instantiate a [wasmtime::component::Component
] within a [wasmtime::Store<T>
]. If you're targeting thewasi:http/proxy
world, you can instantiate the component with [proxy::Proxy::instantiate_async
] or [proxy::sync::Proxy::instantiate
] functions.