Skip to content

Make HTTP requests from inside WASM in wasmedge-quickjs . Devcontainer.

License

Notifications You must be signed in to change notification settings

wasm-outbound-http-examples/wasmedge-quickjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Use WasmEdge-QuickJS to send HTTP(s) requests from inside WASM

This devcontainer is configured to provide you a WasmEdge installation equipped with wasmedge_rustls plugin and a Rust toolchain with wasm32-wasi target to compile the latest WasmEdge-QuickJS.

Open in GitHub Codespaces

Instructions for this devcontainer

Tested with WasmEdge-QuickJS commit f4a4f884, Rustc 1.74.1.

Preparation

  1. Open this repo in devcontainer, e.g. using Github Codespaces. Type or copy/paste following commands to devcontainer's terminal.

Building

  1. Clone WasmEdge-QuickJS repo:
git clone --depth=1 https://github.com/second-state/wasmedge-quickjs.git
  1. cd into the folder of WasmEdge-QuickJS sources:
cd wasmedge-quickjs
  1. Compile the WasmEdge-QuickJS interpreter:
cargo build --target wasm32-wasi --release
  1. Copy wasmedge_quickjs.wasm file to current directory, thus it requires pure JS modules from modules directory in this source distribution to run:
cp target/wasm32-wasi/release/wasmedge_quickjs.wasm ./
  1. Optionally you can optimize the WASM file to run faster with wasmedgec "compiler":
wasmedgec wasmedge_quickjs.wasm wasmedge_quickjs.wasm

This will override the original copy with optimized (and a 1.5 times larger) one.

Test with WasmEdge runtime

wasmedge --dir .:. wasmedge_quickjs.wasm example_js/wasi_https_fetch.js

This test may take about 20 seconds. You can also try lots of other examples in example_js directory, especially wasi_http_fetch.js and
wasi_http_server.js.

Finish

Perform your own experiments if desired.


Created for (wannabe-awesome) list