This commit is contained in:
Nicolas Lepage 2019-12-02 16:58:20 +01:00
parent b4be701615
commit 24d9d2d727
No known key found for this signature in database
GPG Key ID: B0879E35E66D8F6F
2 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>go-wasm-http-server demo</title>
<script src="https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@b4be701615d284296a4a1aaa852db02f139969ee/index.js"></script>
<script>
async function hello() {
res=await fetch('api/hello', {

View File

@ -1,9 +1,11 @@
const swUrl = 'https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@b4be701615d284296a4a1aaa852db02f139969ee/index.js'
window.wasmhttp = {
register: async (wasm, { scope, base = '' } = {}) => {
const options = {}
if (scope) options.scope = scope
//FIXME register once
const registration = await navigator.serviceWorker.register('sw.js', options)
const registration = await navigator.serviceWorker.register(swUrl, options)
await navigator.serviceWorker.ready
registration.active.postMessage({
type: 'wasmhttp.register',