diff --git a/index.js b/index.js new file mode 100644 index 0000000..acecf71 --- /dev/null +++ b/index.js @@ -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)) + }) + } +}