Module 4 · Exercise · ~30 min · Real Go code
Build a minimal HTTP streaming proxy. The shape: forward an inbound request to an upstream, stream the response body back without buffering, count bytes, respect context cancellation. Same architecture as a real Canton transaction-stream proxy.
cd module-04-systems-go/exercises/exercise-01-streaming-proxy
go test -v -race ./...
client ─[GET /x]─▶ Proxy.ServeHTTP ─[GET upstream/x]─▶ upstream
│ │
client ◀─[stream]── ServeHTTP ◀─[chunked stream]───────────┘
▲
BytesIn / BytesOut counters
context cancellation propagates
http.NewRequestWithContext(r.Context(), "GET", url, nil) — propagates cancellation.http.DefaultClient.Do(req) — sends.defer resp.Body.Close() — non-negotiable.io.Copy(w, resp.Body) — streams; returns n bytes copied.