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
|
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.
|
||||||
|
|
||||||
|
@ -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.
@ -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())
|
||||||
|
@ -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())
|
||||||
|
@ -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.
@ -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())
|
||||||
|
@ -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.
@ -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())
|
||||||
|
@ -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
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
|
go 1.18
|
||||||
|
|
||||||
|
@ -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 (
|
||||||
|
@ -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 {
|
||||||
|
@ -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 {
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user