DEV Community

Cover image for Emulate a Go HTTP server in your browser
Nicolas Lepage
Nicolas Lepage

Posted on

Emulate a Go HTTP server in your browser

Hi 👋 I'd like to share

GitHub logo nlepage / go-wasm-http-server

WebAssembly Go HTTP Server embedded in a ServiceWorker

Welcome to go-wasm-http-server 👋

Go Reference License: Apache 2.0 Twitter: njblepage

Build your Go HTTP Server to WebAssembly and embed it in a ServiceWorker!



Talk given at the Go devroom of FOSDEM 2021 explaining how go-wasm-http-server works:

Deploy a Go HTTP server in your browser Youtube link

The slides are available here.


go-wasm-http-server can help you put up a demonstration for a project without actually running a Go HTTP server.


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)


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.


Top comments (0)