Crate wasmtime_wasi_http
source ·Expand description
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
inwasmtime::Store<T>
. - Add WASI HTTP interfaces to a
wasmtime::component::Linker<T>
. This is either done through functions likeproxy::add_to_linker
(which bundles all interfaces in thewasi:http/proxy
world together) or through individual interfaces like thebindings::http::outgoing_handler::add_to_linker_get_host
function. - Use the previous
wasmtime::component::Linker<T>::instantiate
to instantiate awasmtime::component::Component
within awasmtime::Store<T>
. If you’re targeting thewasi:http/proxy
world, you can instantiate the component withproxy::Proxy::instantiate_async
orproxy::sync::Proxy::instantiate
functions.
Modules§
- Raw bindings to the
wasi:http
package. - Implementation of the
wasi:http/types
interface’s various body types. - I/O utility for bridging between
tokio::io
andhyper::rt
. - Implementation of the
wasi:http/proxy
world. - Implements the base structure (i.e. WasiHttpCtx) that will provide the implementation of the wasi-http API.
Structs§
- A
wasi:http
-specific error type used to represent either a trap or anErrorCode
. - Capture the state necessary for use in the wasi-http API implementation.
- A concrete structure that all generated
Host
traits are implemented for.
Traits§
- A trait which provides internal WASI HTTP state.
Functions§
- Translate a
http::Error
to a wasi-httpErrorCode
in the context of a request. - Translate a
hyper::Error
to a wasi-httpErrorCode
in the context of a request. - Translate a
hyper::Error
to a wasi-httpErrorCode
in the context of a response.