/cf-workers-web-app

Simple web app example for Cloudflare workers.

Primary LanguageRustApache License 2.0Apache-2.0

Cloudflare Workers Web App

Simple web app example for Cloudflare workers.

Built with waserv

Cloudflare Workers + WASM + Rust = ❀️

API Endpoints

  • GET / {"message":"Hello, World!"}
  • GET /hello/mehmetcan {"message":"Hello, mehmetcan!"}

Install

  1. Install Rust
  2. Install Wrangler
  3. Install wasm-pack
# 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

Development

  1. wrangler dev

Benchmark

$ ab -c 10 -n 1000 https://cloudflare_worker_url/

Requests: 1k Median CPU Time: 0.7ms

πŸ‘·β€β™€οΈπŸ¦€πŸ•ΈοΈ rustwasm-worker-template

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.

πŸ”‹ Batteries Included

🚴 Usage

πŸ‘ Use wrangler generate to Clone this Template

Learn more about wrangler generate here.

wrangler generate wasm-worker  https://github.com/cloudflare/rustwasm-worker-template.git
cd wasm-worker

πŸ› οΈ Build with wasm-pack build

wasm-pack build

πŸ”¬ Test in Headless Browsers with wasm-pack test

wasm-pack test --headless --firefox