Skip to content

Instantly share code, notes, and snippets.

@kt3k
Last active June 2, 2021 15:36
Show Gist options
  • Save kt3k/df0b55513544a006ec5db08b20de2c6c to your computer and use it in GitHub Desktop.
Save kt3k/df0b55513544a006ec5db08b20de2c6c to your computer and use it in GitHub Desktop.
addEventListener("fetch", (e) => {
e.respondWith((async () => {
let result: string;
const { request } = e;
if (request.body == null) {
result = "request body is empty\n";
} else {
result = `request body length = ${(await request.arrayBuffer()).byteLength}\n`;
}
return new Response(result)
})());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment