chore: v2.0.0

This commit is contained in:
Nicolas Lepage 2024-10-14 22:24:46 +02:00
parent b7e5adfd23
commit 23cde9d811
No known key found for this signature in database
GPG Key ID: B0879E35E66D8F6F
20 changed files with 23 additions and 23 deletions

View File

@ -72,7 +72,7 @@ becomes:
package main package main
import ( import (
wasmhttp "github.com/nlepage/go-wasm-http-server" wasmhttp "github.com/nlepage/go-wasm-http-server/v2"
) )
func main() { func main() {
@ -97,7 +97,7 @@ Create a ServiceWorker file with the following code:
📄 `sw.js` 📄 `sw.js`
```js ```js
importScripts('https://cdn.jsdelivr.net/gh/golang/go@go1.18.4/misc/wasm/wasm_exec.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') 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 ### 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. Instantiates and runs the WebAssembly module at `wasmUrl`, and registers a fetch listener forwarding requests to the WebAssembly module's server.

View File

@ -6,7 +6,7 @@ import (
"github.com/tmaxmax/go-sse" "github.com/tmaxmax/go-sse"
wasmhttp "github.com/nlepage/go-wasm-http-server" wasmhttp "github.com/nlepage/go-wasm-http-server/v2"
) )
func main() { func main() {

Binary file not shown.

View File

@ -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/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) => { addEventListener('install', (event) => {
event.waitUntil(skipWaiting()) event.waitUntil(skipWaiting())

View File

@ -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/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 => { addEventListener('install', event => {
event.waitUntil(skipWaiting()) event.waitUntil(skipWaiting())

View File

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
"sync/atomic" "sync/atomic"
wasmhttp "github.com/nlepage/go-wasm-http-server" wasmhttp "github.com/nlepage/go-wasm-http-server/v2"
) )
func main() { func main() {

Binary file not shown.

View File

@ -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/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) => { addEventListener('install', (event) => {
event.waitUntil(skipWaiting()) event.waitUntil(skipWaiting())

View File

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
wasmhttp "github.com/nlepage/go-wasm-http-server" wasmhttp "github.com/nlepage/go-wasm-http-server/v2"
) )
func main() { func main() {

Binary file not shown.

View File

@ -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/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) => { addEventListener('install', (event) => {
event.waitUntil(skipWaiting()) event.waitUntil(skipWaiting())

View File

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"net/http" "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. // Demonstrates a simple hello JSON service.

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/nlepage/go-wasm-http-server module github.com/nlepage/go-wasm-http-server/v2
go 1.18 go 1.18

View File

@ -3,7 +3,7 @@ package jstype
import ( import (
"syscall/js" "syscall/js"
"github.com/nlepage/go-wasm-http-server/internal/safejs" "github.com/nlepage/go-wasm-http-server/v2/internal/safejs"
) )
var ( var (

View File

@ -5,7 +5,7 @@ import (
promise "github.com/nlepage/go-js-promise" 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 { type Reader struct {

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"io" "io"
"github.com/nlepage/go-wasm-http-server/internal/jstype" "github.com/nlepage/go-wasm-http-server/v2/internal/jstype"
"github.com/nlepage/go-wasm-http-server/internal/safejs" "github.com/nlepage/go-wasm-http-server/v2/internal/safejs"
) )
type Writer struct { type Writer struct {

View File

@ -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 package wasmhttp

View File

@ -5,8 +5,8 @@ import (
"net/http/httptest" "net/http/httptest"
"syscall/js" "syscall/js"
"github.com/nlepage/go-wasm-http-server/internal/readablestream" "github.com/nlepage/go-wasm-http-server/v2/internal/readablestream"
"github.com/nlepage/go-wasm-http-server/internal/safejs" "github.com/nlepage/go-wasm-http-server/v2/internal/safejs"
) )
// Request builds and returns the equivalent http.Request // Request builds and returns the equivalent http.Request

View File

@ -11,9 +11,9 @@ import (
promise "github.com/nlepage/go-js-promise" promise "github.com/nlepage/go-js-promise"
"github.com/nlepage/go-wasm-http-server/internal/jstype" "github.com/nlepage/go-wasm-http-server/v2/internal/jstype"
"github.com/nlepage/go-wasm-http-server/internal/readablestream" "github.com/nlepage/go-wasm-http-server/v2/internal/readablestream"
"github.com/nlepage/go-wasm-http-server/internal/safejs" "github.com/nlepage/go-wasm-http-server/v2/internal/safejs"
) )
type Response interface { type Response interface {

View File

@ -7,7 +7,7 @@ import (
"strings" "strings"
"syscall/js" "syscall/js"
"github.com/nlepage/go-wasm-http-server/internal/safejs" "github.com/nlepage/go-wasm-http-server/v2/internal/safejs"
) )
var ( var (