This commit is contained in:
Nicolas Lepage 2019-11-27 01:12:09 +01:00
parent 1878cef269
commit 40c75880da
No known key found for this signature in database
GPG Key ID: B0879E35E66D8F6F

16
index.js Normal file
View File

@ -0,0 +1,16 @@
self.wasmhttp = {
Serve: async (wasm) => {
const go = new Go()
const { instance } = await WebAssembly.instantiateStreaming(fetch(wasm), go.importObject)
try {
await go.run(instance)
} catch (e) {
console.error(e)
}
addEventListener('fetch', async e => {
if (new URL(e.request.url).pathname !== '/test') return
e.respondWith((await fetchHandler)(e.request))
})
}
}