Hi 👋 I'd like to share github.com/nlepage/go-wasm-http-server
nlepage / go-wasm-http-server
WebAssembly Go HTTP Server embedded in a ServiceWorker
Welcome to go-wasm-http-server 👋
Build your Go HTTP Server to WebAssembly and embed it in a ServiceWorker!
Examples
- Hello example (sources)
- Hello example with state (sources)
- Hello example with state and keepalive (sources)
-
😺 Catption generator example (sources) - Random password generator web server (sources forked from jbarham/random-password-please)
How?
Talk given at the Go devroom of FOSDEM 2021 explaining how go-wasm-http-server
works:
The slides are available here.
Why?
go-wasm-http-server
can help you put up a demonstration for a project without actually running a Go HTTP server.
Requirements
go-wasm-http-server
requires you to build your Go application to WebAssembly, so you need to make sure your code is compatible:
- no C bindings
- no System dependencies such as file system or network (database server for example)
Usage
Step 1: Build to js/wasm
In your Go code, replace http.ListenAndServe()
(or net.Listen()
+ http.Serve()
)…
This project allows you to build Go HTTP handlers to WebAssembly and embed it in a ServiceWorker to emulate an HTTP server!
I'd really appreciate to have feedback from people who would give it a try 🙂
The readme has a usage section and some examples to guide you.
Here is a video from FOSDEM 21 explaining how this works:
Contributions on the project are more than welcome.
Thanks!
Top comments (1)
Hi,
Great work! I work on a fork of the repo. I have a question regarding porting a websocket connexion to this "in browser connexion". How can I contact you ?
BR,
Thomas