An example project showing how to build a spec-compliant
wasi:http/proxy server for WASI 0.2 written in JavaScript.
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
/upload # Echo uploaded blob
Testing routes:
# Hello world
$ curl localhost:8080
# Sleep for {ms} milliseconds
$ curl localhost:8080/sleep/2000
# Echo the HTTP body
$ curl -d "Test echo body" localhost:8080/echo
# Echo the HTTP headers
$ curl -H "X-Test-Header: 123" localhost:8080/echo-headers
# Echo uploaded blob
$ echo "Hello World!" > test_file.txt
$ curl -H "Content-Type: text/plain" --data-binary @test_file.txt http://localhost:8080/uploadThe 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 | bashTo build and serve the wasm component on localhost:8080:
$ npm install
$ npm run serveThen send requests to the component:
$ curl localhost:8080$ npm run build # Build the wasm component
$ npm test # Run tests
$ npm run fmt # Format code
$ npm run fmt:check # Check formatting
$ npm run lint # Lint code
$ npm run wit:fetch # Fetch WIT dependencies
$ npm run wit:update # Update WIT lock file- sample-wasi-http-rust An example
wasi:httpserver component written in Rust.
Apache-2.0 with LLVM Exception