Something went wrong. Try again.
Cloudflare Cap'n'Web Go implementation
Something went wrong. Try again.
1 folder · 2 files
README.md
Playground — browser UI + Go backend #
A minimal end-to-end demo: a Go Cap'n Web
server called from the browser with the reference capnweb client over
WebSocket. It exercises the headline features of the protocol.
Run #
go run ./examples/playground
# open http://127.0.0.1:8088
No frontend build step — web/app.js is a native ES module that imports the
capnweb client from a CDN (esm.sh), so an internet connection is needed the
first time the page loads. The Go server serves the embedded UI and the
WebSocket RPC endpoint at /ws.
What it shows #
greet/add— plain RPC calls with typed arguments and return values.counter—NewCounter()returns a live server-side object by reference; eachIncrement()is a call on that remote stub, and its state lives on the server.- pipelining —
api.NewCounter().Add(10)pipes the counter promise straight into.Addwithout awaiting it, so both calls travel in a single round trip.
Layout #
main.go— thePlaygroundbootstrap service (Greet,Add,NewCounter), theCounterRpcTarget, and an HTTP server that embeds and servesweb/.web/index.html,web/app.js— the browser UI (// @ts-check+ JSDoc for editor type-checking without a compiler).