An example project showing how to build a spec-compliant
wasi:http/proxy
server for WASI 0.2 written in JavaScript.
Check also the sibling Rust project sample-wasi-http-rust
The following HTTP routes are available from the component:
/ # Hello world
/sleep # Sleep for {ms} milliseconds
/echo # Echo the HTTP body
/echo-headers # Echo the HTTP headers
/echo-trailers # Echo the HTTP trailers
/upload # Echo uploaded blob
The project uses Wasmtime
as its runtime. However, if needed, it
can easily be adjusted to use jco
instead. For wasmtime
installation,
simply run:
$ curl https://wasmtime.dev/install.sh -sSf | bash
The quickest way to start is by using just
.
$ just serve # to build and serve the wasm component on `localhost:8080`
$ curl 127.0.0.1:8080 # to send requests to component.
Alternatively, run:
$ npm install
$ npm build
$ wasmtime serve -S common dist/server.component.wasm
Apache-2.0 with LLVM Exception