~/talk

Deploy a Go HTTP server in your browser

Talkat FOSDEM 2021 · on Saturday, 2021-02-06· at 14:00· D.go· [webassembly, web-platform]
slides:none on file

Shows that a Go HTTP handler can run inside a browser by compiling to WebAssembly and wiring it into a ServiceWorker: registers a JS callback from Go via syscall/js, converts JS Request to a net/http Request using http.Test NewRequest and copies bodies with copyBytesToGo/copyBytesToJS, uses ResponseRecorder to capture handler output and returns a JS Response Promise. Demo serves an image-captioning form and a JSON hello API; it works but is slower and cannot host long‑running state because ServiceWorker lifecycle kills the WASM.

AI-written summary · about

  1. 0:00Intro
  2. 2:21Build to WebAssembly
  3. 3:48Respond from a Service Worker
  4. 4:43Building a Go HTTP server
  5. 6:33The plan
  6. 7:38Adding is/wasm target server.go
  7. 8:45Implementing wasmhttp.Serve()
  8. 9:42Sending requests to Go sw.js
  9. 10:39Promise for a Response
  10. 11:58JS Request to Go Request
  11. 14:21Calling the HTTP Handler
  12. 15:59Go Response to JS Response
  13. 16:28Resolve Response Promise
  14. 16:43Sending back the Response sw.js
  15. 19:10JSON hello example Click the gopher!
  16. 21:00Catption example Click the gopher!
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.