This commit is contained in:
Nicolas Lepage 2021-01-21 23:28:52 +01:00
parent 50ea469fdf
commit 9ee7a321b6
No known key found for this signature in database
GPG Key ID: B0879E35E66D8F6F

8
sw.js
View File

@ -15,7 +15,7 @@ function registerWasmHTTPListener(wasm, base, args) {
let path = new URL(registration.scope).pathname let path = new URL(registration.scope).pathname
if (base && base !== '') path = `${trimEnd(path, '/')}/${trimStart(base, '/')}` if (base && base !== '') path = `${trimEnd(path, '/')}/${trimStart(base, '/')}`
addEventListener('fetch', async e => { addEventListener('fetch', e => {
console.log("new fetch !") console.log("new fetch !")
const { pathname } = new URL(e.request.url) const { pathname } = new URL(e.request.url)
@ -29,11 +29,7 @@ function registerWasmHTTPListener(wasm, base, args) {
// FIXME await ? catch ? // FIXME await ? catch ?
startWasm(wasm, { env: { WASMHTTP_HANDLER_ID: handlerId, WASMHTTP_PATH: path }, args }) startWasm(wasm, { env: { WASMHTTP_HANDLER_ID: handlerId, WASMHTTP_PATH: path }, args })
const handler = await handlerPromise e.respondWith(handlerPromise.then(handler => handler(e.request)))
console.log({ handler })
e.respondWith(handler(e.request))
}) })
} }