A lightweight Go gateway that forwards trade and task traffic, validates JWT tokens, enforces basic security headers and rate limits, performs readiness checks against upstream services, and serves the merged OpenAPI contract for the platform.
- Install Go 1.22 or newer.
- Generate a starter config:
go run ./cmd/apigw init --path gateway.yaml(edit upstream URLs, JWT, and CORS as needed;config/examples/gateway.sample.yamlshows a fully commented template). - Optionally export environment overrides (see
AGENTS.mdfor accepted variables). - Start the gateway:
go run ./cmd/apigw run --config gateway.yaml(edit upstream URLs, JWT, and CORS as needed; seeconfig/examples/gateway.sample.yaml). - Verify the service at
http://localhost:8080/healthandhttp://localhost:8080/readyz. - Optional: run the gateway as a background service via
go run ./cmd/apigw daemon start --config gateway.yaml --pid apigw.pid --log apigw.log --background. Pair withADMIN_TOKENor theadmin.tokenYAML setting to secure the control-plane endpoints.
go test ./...– run the test suite.golangci-lint run ./...– enforce formatting and static analysis (matches CI checks).go run ./cmd/apigw run --config gateway.yaml– boot the HTTP gateway with the YAML/env loader.go run ./cmd/apigw run --config gateway.yaml --watch– hot-reload the gateway when the config file changes.go run ./cmd/apigw daemon start --config gateway.yaml --pid apigw.pid --log apigw.log --background– launch and detach the managed daemon.go run ./cmd/apigw admin status --url http://127.0.0.1:9090 --token <token>– query the control-plane status endpoint (configandreloadsubcommands also available).go run ./cmd/apigw daemon stop --pid apigw.pid– send SIGTERM and wait for shutdown.go run ./cmd/apigw daemon status --pid apigw.pid– inspect the current daemon process.go run ./cmd/apigw convert-env --output gateway.yaml– snapshot environment-driven configuration into a YAML file (use--forceto overwrite existing files or--configto merge from an existing YAML).go run ./cmd/gateway– legacy entrypoint (delegates to the runtime under the hood).go run ./cmd/openapi --out dist/openapi.json– regenerate the merged OpenAPI document.scripts/shadowdiff-run.sh– start mock upstreams, run the Go gateway, and optionally diff against a reference Node deployment by settingNODE_BASE_URL.scripts/smoke/smoke.sh– run smoke checks against a running instance (setSMOKE_JWTto exercise proxy routes).
- Documentation site (Docusaurus):
cd docs && npm start - Legacy docs (archived):
docs-archive/
apigw daemon startwrites a pid file and (optionally) a log file before booting the runtime. Add--backgroundto detach; the parent prints the daemon pid so you can stash it in supervisors or scripts.apigw daemon stop --pid apigw.pidtears down the managed process. Use--signal(for example,SIGINT,SIGTERM, orSIGKILL) and--waitto tune shutdown behaviour; stale pid files are automatically cleaned up.apigw daemon status --pid apigw.pidreports whether the pid file points at a live process (daemon running) or has already exited (daemon not running).apigw admin <status|config|reload>targets the HTTP control-plane. Pair the--urlflag with--tokenwhenADMIN_TOKENoradmin.tokenis set, and lock down access withADMIN_ALLOW/admin.allow.- Store daemon log output via
--logor by exportingAPIGW_LOG_PATH. The path is propagated to the runtime so the same Zap logger flows through admin and proxy requests.
cmd/apigw/– CLI for running, validating, and bootstrapping gateway configs.cmd/gateway/– compatibility wrapper that runs the runtime with the current config.cmd/openapi/– helper CLI for regenerating the merged OpenAPI document.internal/– domain-specific helpers (OpenAPI merge service, readiness probes, shadow diff harness).pkg/gateway/– reusable SDK packages (auth,config,metrics,problem,proxy,runtime,server,server/middleware,daemon).pkg/– shared logging and metrics utilities.shadowdiff/– traffic replay fixtures and helpers.specs/– OpenAPI fragments merged at runtime/build time.
A multi-stage Dockerfile is provided. render.yaml contains an example Render service definition pointing to the Go gateway container.
Additional deployment assets live in deploy/:
deploy/docker/Dockerfile– reference container build with usage notes indeploy/docker/README.md.deploy/systemd/apigw.service– systemd unit template explained indeploy/systemd/README.md.
See docs-archive/examples.md for runnable samples:
- Programmatic runtime embedding (
examples/basic). - CLI-driven multi-upstream config (
examples/multi-upstream). - TLS/mTLS configuration (
examples/tls-mtls).
- CI (
.github/workflows/ci.yml) runs formatting, linting, tests, and publishes the merged OpenAPI artifact. - Tagged releases (
v*) trigger GoReleaser (.github/workflows/release.yml) to build cross-platform binaries—seedocs-archive/releases.mdfor the full workflow.
Follow the guidelines in AGENTS.md, run tests and linting before opening a pull request, and use Conventional Commit messages (for example, feat(gateway): add trade proxy metrics). Please include validation commands and any relevant smoke test output in pull requests.