http-wasm Guest Library
This library provides a Rust implementation for the Wasm Guest ABI and interfaces with http-wasm.
It is designed for writing Traefik plugins in Rust, and works with any http-wasm compatible runtime.
Design Goals
- Minimal dependency footprint: only the
logcrate is required at runtime. - Low-level
Byteabstraction to enable all use-cases. - Memory-efficient data handling to suit constrained Wasm environments.
Credits
- Initial reference code from http-wasm-rust
- API inspired by http-wasm-guest-tinygo
Usage
Add the dependency to your project:
cargo add http-wasm-guest
Implement the Guest trait and register the plugin. See the examples for complete code.
use ;
/// A minimal plugin that adds a custom header to each request.
;
/// Registers the plugin with the http-wasm runtime.
Build
Add the WASI target for building the plugin:
rustup target add wasm32-wasip1
Build the plugin with
cargo build --target wasm32-wasip1 --release
Deploy
plugins/
└── src
└── plugindemowasm
└── plugin.wasm