Simple web app example for Cloudflare workers.
Built with waserv
Cloudflare Workers + WASM + Rust = ❤️
- GET / {"message":"Hello, World!"}
- GET /hello/mehmetcan {"message":"Hello, mehmetcan!"}
# Install wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
wrangler generate cf-wasm-worker-name https://github.com/mehmetcansahin/cf-workers-web-app.git
cd cf-wasm-worker-name
- wrangler dev
$ ab -c 10 -n 1000 https://cloudflare_worker_url/
Requests: 1k Median CPU Time: 0.7ms
A template for kick starting a Cloudflare worker project using
wasm-pack
.
This template is designed for compiling Rust libraries into WebAssembly and publishing the resulting worker to Cloudflare's worker infrastructure.
wasm-bindgen
for communicating between WebAssembly and JavaScript.console_error_panic_hook
for logging panic messages to the developer console.wee_alloc
, an allocator optimized for small code size.
Learn more about wrangler generate
here.
wrangler generate wasm-worker https://github.com/cloudflare/rustwasm-worker-template.git
cd wasm-worker
wasm-pack build
wasm-pack test --headless --firefox