diff --git a/docs/api.go b/docs/api.go index 70386f1..def96b7 100644 --- a/docs/api.go +++ b/docs/api.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "net/http" + "time" wasmhttp "github.com/nlepage/go-wasm-http-server" ) @@ -11,9 +12,10 @@ import ( var no = 1 func main() { - fmt.Println("Starting...") - http.HandleFunc("/hello", func(res http.ResponseWriter, req *http.Request) { + h, m, s := time.Now().Clock() + fmt.Printf("hello at %02d:%02d:%02d\n", h, m, s) + params := make(map[string]string) if err := json.NewDecoder(req.Body).Decode(¶ms); err != nil { panic(err) @@ -29,7 +31,12 @@ func main() { wasmhttp.Serve(nil) - fmt.Println("Started") + go func() { + for range time.Tick(time.Second) { + h, m, s := time.Now().Clock() + fmt.Printf("tick at %02d:%02d:%02d\n", h, m, s) + } + }() select {} } diff --git a/docs/api.wasm b/docs/api.wasm index 08a0014..34918f3 100755 Binary files a/docs/api.wasm and b/docs/api.wasm differ diff --git a/sw.js b/sw.js index 780af8f..9506ab2 100644 --- a/sw.js +++ b/sw.js @@ -64,7 +64,7 @@ addEventListener('message', async ({ data }) => { startWasm(wasm, handlerId, path) running.add(key) - // FIXME try catch + // FIXME try catch handlers.push([path, await handler]) } })