gw-03 — Execution
Prerequisites
- Go ≥ 1.25 (stdlib only, offline). Optional:
curl,python3.
One-shot
cd gw-03-api-gateway && bash scripts/verify.sh # → "=== gw-03 OK ==="
Per-language workflow (Go)
cd gw-03-api-gateway/src/go
go test -race -count=1 ./... # 8 tests in package gateway
go build -o /tmp/gateway ./cmd/gateway
Run it
python3 -m http.server 9000 &
/tmp/gateway -listen :8080 -route /v1=http://127.0.0.1:9000
curl -i localhost:8080/healthz # 200 (exempt)
curl -i localhost:8080/v1/x # 401 (no token)
curl -i -H 'Authorization: Bearer t' localhost:8080/v1/ # 200 via origin
curl -i -H 'Authorization: Bearer t' localhost:8080/nope # 404 (no route)
-route prefix=originURL is repeatable. Ctrl-C drains in-flight via
http.Server.Shutdown.
Package map
| File | What |
|---|---|
gateway/gateway.go | the filter-chain engine (phases, context, panic isolation) |
gateway/routing.go | route table + atomic hot-reload + specificity matching |
gateway/filters.go | auth, local + proxy endpoints, access log, error normalizer, hop-by-hop hygiene |
cmd/gateway | the runnable gateway |
See GUIDE.md for the deep walkthrough.