mirror of
https://github.com/cloudflare/workers-rs.git
synced 2025-12-08 18:01:59 +00:00
* Initially adding files. * Move examples, add to cargo build. * remove files * Fix KV paths and link dependencies to workspace. * Add test package to cargo.lock * Update kv test dependencies. * Add send/sync to KvStore. * Remove dead code. * Fix cargo.lock * Undo cargo.lock changes. * Fix formatting. * Make code idiomatic.
28 lines
574 B
JavaScript
28 lines
574 B
JavaScript
addEventListener("fetch", (event) => {
|
|
event.respondWith(handleRequest(event.request));
|
|
});
|
|
|
|
/**
|
|
* Fetch and log a request
|
|
* @param {Request} request
|
|
*/
|
|
async function handleRequest() {
|
|
const { start } = wasm_bindgen;
|
|
await wasm_bindgen(wasm);
|
|
|
|
try {
|
|
const text = await start();
|
|
|
|
return new Response(text, {
|
|
status: 200,
|
|
headers: {
|
|
"Content-type": "application/json",
|
|
},
|
|
});
|
|
} catch (error) {
|
|
return new Response(error, {
|
|
status: 500,
|
|
});
|
|
}
|
|
}
|