mirror of
https://github.com/nlepage/go-wasm-http-server.git
synced 2025-03-10 17:29:10 +00:00
🚧
This commit is contained in:
parent
1878cef269
commit
40c75880da
16
index.js
Normal file
16
index.js
Normal 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))
|
||||
})
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user