diff --git a/README.md b/README.md index 57b7ea6..c266a68 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ becomes: package main import ( - wasmhttp "github.com/nlepage/go-wasm-http-server" + wasmhttp "github.com/nlepage/go-wasm-http-server/v2" ) func main() { @@ -97,7 +97,7 @@ Create a ServiceWorker file with the following code: 📄 `sw.js` ```js importScripts('https://cdn.jsdelivr.net/gh/golang/go@go1.18.4/misc/wasm/wasm_exec.js') -importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js') +importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v2.0.0/sw.js') registerWasmHTTPListener('path/to/server.wasm') ``` @@ -144,7 +144,7 @@ For Go API see [pkg.go.dev/github.com/nlepage/go-wasm-http-server](https://pkg.g ### JavaScript API -### [`registerWasmHTTPListener(wasmUrl, options)`](https://github.com/nlepage/go-wasm-http-server/blob/v1.0.0/sw.js#L3) +### `registerWasmHTTPListener(wasmUrl, options)` Instantiates and runs the WebAssembly module at `wasmUrl`, and registers a fetch listener forwarding requests to the WebAssembly module's server. diff --git a/docs/hello-sse/api.go b/docs/hello-sse/api.go index 6e94306..5259950 100644 --- a/docs/hello-sse/api.go +++ b/docs/hello-sse/api.go @@ -6,7 +6,7 @@ import ( "github.com/tmaxmax/go-sse" - wasmhttp "github.com/nlepage/go-wasm-http-server" + wasmhttp "github.com/nlepage/go-wasm-http-server/v2" ) func main() { diff --git a/docs/hello-sse/api.wasm b/docs/hello-sse/api.wasm index 1e8eeac..568e5f8 100755 Binary files a/docs/hello-sse/api.wasm and b/docs/hello-sse/api.wasm differ diff --git a/docs/hello-sse/sw.js b/docs/hello-sse/sw.js index df8ff57..7e959cd 100644 --- a/docs/hello-sse/sw.js +++ b/docs/hello-sse/sw.js @@ -1,5 +1,5 @@ importScripts('https://cdn.jsdelivr.net/gh/golang/go@go1.23.1/misc/wasm/wasm_exec.js') -importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js') +importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v2.0.0/sw.js') addEventListener('install', (event) => { event.waitUntil(skipWaiting()) diff --git a/docs/hello-state-keepalive/sw.js b/docs/hello-state-keepalive/sw.js index 5123ea9..eb80955 100644 --- a/docs/hello-state-keepalive/sw.js +++ b/docs/hello-state-keepalive/sw.js @@ -1,5 +1,5 @@ importScripts('https://cdn.jsdelivr.net/gh/golang/go@go1.23.1/misc/wasm/wasm_exec.js') -importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js') +importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v2.0.0/sw.js') addEventListener('install', event => { event.waitUntil(skipWaiting()) diff --git a/docs/hello-state/api.go b/docs/hello-state/api.go index a93fcd1..50cf4de 100644 --- a/docs/hello-state/api.go +++ b/docs/hello-state/api.go @@ -6,7 +6,7 @@ import ( "net/http" "sync/atomic" - wasmhttp "github.com/nlepage/go-wasm-http-server" + wasmhttp "github.com/nlepage/go-wasm-http-server/v2" ) func main() { diff --git a/docs/hello-state/api.wasm b/docs/hello-state/api.wasm index e77fd53..c63bd29 100755 Binary files a/docs/hello-state/api.wasm and b/docs/hello-state/api.wasm differ diff --git a/docs/hello-state/sw.js b/docs/hello-state/sw.js index 3371bbc..c137cd2 100644 --- a/docs/hello-state/sw.js +++ b/docs/hello-state/sw.js @@ -1,5 +1,5 @@ importScripts('https://cdn.jsdelivr.net/gh/golang/go@go1.23.1/misc/wasm/wasm_exec.js') -importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js') +importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v2.0.0/sw.js') addEventListener('install', (event) => { event.waitUntil(skipWaiting()) diff --git a/docs/hello/api.go b/docs/hello/api.go index 8b25e4f..6798287 100644 --- a/docs/hello/api.go +++ b/docs/hello/api.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - wasmhttp "github.com/nlepage/go-wasm-http-server" + wasmhttp "github.com/nlepage/go-wasm-http-server/v2" ) func main() { diff --git a/docs/hello/api.wasm b/docs/hello/api.wasm index aab5867..f5d2042 100755 Binary files a/docs/hello/api.wasm and b/docs/hello/api.wasm differ diff --git a/docs/hello/sw.js b/docs/hello/sw.js index df8ff57..7e959cd 100644 --- a/docs/hello/sw.js +++ b/docs/hello/sw.js @@ -1,5 +1,5 @@ importScripts('https://cdn.jsdelivr.net/gh/golang/go@go1.23.1/misc/wasm/wasm_exec.js') -importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js') +importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v2.0.0/sw.js') addEventListener('install', (event) => { event.waitUntil(skipWaiting()) diff --git a/example_json_test.go b/example_json_test.go index 15b9149..3b5fbfd 100644 --- a/example_json_test.go +++ b/example_json_test.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - wasmhttp "github.com/nlepage/go-wasm-http-server" + wasmhttp "github.com/nlepage/go-wasm-http-server/v2/v2" ) // Demonstrates a simple hello JSON service. diff --git a/go.mod b/go.mod index 4309103..16684a8 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/nlepage/go-wasm-http-server +module github.com/nlepage/go-wasm-http-server/v2 go 1.18 diff --git a/internal/jstype/types.go b/internal/jstype/types.go index 5077176..71cb0b5 100644 --- a/internal/jstype/types.go +++ b/internal/jstype/types.go @@ -3,7 +3,7 @@ package jstype import ( "syscall/js" - "github.com/nlepage/go-wasm-http-server/internal/safejs" + "github.com/nlepage/go-wasm-http-server/v2/internal/safejs" ) var ( diff --git a/internal/readablestream/reader.go b/internal/readablestream/reader.go index f56c950..854f6fd 100644 --- a/internal/readablestream/reader.go +++ b/internal/readablestream/reader.go @@ -5,7 +5,7 @@ import ( promise "github.com/nlepage/go-js-promise" - "github.com/nlepage/go-wasm-http-server/internal/safejs" + "github.com/nlepage/go-wasm-http-server/v2/internal/safejs" ) type Reader struct { diff --git a/internal/readablestream/writer.go b/internal/readablestream/writer.go index 6b84fc5..7047a55 100644 --- a/internal/readablestream/writer.go +++ b/internal/readablestream/writer.go @@ -4,8 +4,8 @@ import ( "context" "io" - "github.com/nlepage/go-wasm-http-server/internal/jstype" - "github.com/nlepage/go-wasm-http-server/internal/safejs" + "github.com/nlepage/go-wasm-http-server/v2/internal/jstype" + "github.com/nlepage/go-wasm-http-server/v2/internal/safejs" ) type Writer struct { diff --git a/package.go b/package.go index aaf4c75..f6b59f7 100644 --- a/package.go +++ b/package.go @@ -1,2 +1,2 @@ -// Package wasmhttp (github.com/nlepage/go-wasm-http-server) allows to create a WebAssembly Go HTTP Server embedded in a ServiceWorker. +// Package wasmhttp allows to create a WebAssembly Go HTTP Server embedded in a ServiceWorker. package wasmhttp diff --git a/request.go b/request.go index 36357e6..d45dbbc 100644 --- a/request.go +++ b/request.go @@ -5,8 +5,8 @@ import ( "net/http/httptest" "syscall/js" - "github.com/nlepage/go-wasm-http-server/internal/readablestream" - "github.com/nlepage/go-wasm-http-server/internal/safejs" + "github.com/nlepage/go-wasm-http-server/v2/internal/readablestream" + "github.com/nlepage/go-wasm-http-server/v2/internal/safejs" ) // Request builds and returns the equivalent http.Request diff --git a/response.go b/response.go index 70b538c..76385d0 100644 --- a/response.go +++ b/response.go @@ -11,9 +11,9 @@ import ( promise "github.com/nlepage/go-js-promise" - "github.com/nlepage/go-wasm-http-server/internal/jstype" - "github.com/nlepage/go-wasm-http-server/internal/readablestream" - "github.com/nlepage/go-wasm-http-server/internal/safejs" + "github.com/nlepage/go-wasm-http-server/v2/internal/jstype" + "github.com/nlepage/go-wasm-http-server/v2/internal/readablestream" + "github.com/nlepage/go-wasm-http-server/v2/internal/safejs" ) type Response interface { diff --git a/serve.go b/serve.go index 2c5488b..05cda45 100644 --- a/serve.go +++ b/serve.go @@ -7,7 +7,7 @@ import ( "strings" "syscall/js" - "github.com/nlepage/go-wasm-http-server/internal/safejs" + "github.com/nlepage/go-wasm-http-server/v2/internal/safejs" ) var (