mirror of
https://github.com/nlepage/go-wasm-http-server.git
synced 2025-03-10 09:27:08 +00:00
chore: v2.0.0
This commit is contained in:
parent
b7e5adfd23
commit
23cde9d811
@ -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.
|
||||
|
||||
|
@ -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() {
|
||||
|
Binary file not shown.
@ -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())
|
||||
|
@ -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())
|
||||
|
@ -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() {
|
||||
|
Binary file not shown.
@ -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())
|
||||
|
@ -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() {
|
||||
|
Binary file not shown.
@ -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())
|
||||
|
@ -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.
|
||||
|
2
go.mod
2
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
|
||||
|
||||
|
@ -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 (
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user