mirror of
https://github.com/hanzoai/gateway.git
synced 2026-10-30 15:04:44 +00:00
* feat(cloud-mount): port gateway to HIP-0106 Mount(*zip.App, cloud.Deps)
Add pkg/gateway/mount.go (build tag: cloud) exposing the canonical
HIP-0106 contract so the unified hanzoai/cloud binary can co-resident
the gateway trust boundary without standing a second JWT validator up
in-process.
The mount does three things:
1. Installs the existing NewAuthMiddleware as a zip middleware via a
gin -> net/http -> zip adaptor. Same strip-list, same JWKS cache,
same X-* mint list as the standalone cmd/gateway binary — one
trust boundary, one implementation.
2. Registers a native zip /_/gateway/healthz endpoint independent of
the auth chain so probes work even with a misconfigured JWKS.
3. Best-effort loads the routes table from GATEWAY_ROUTES_FILE; a
missing file is non-fatal in cloud-mode (co-resident subsystems
own their own routes), unlike the standalone path which fails
closed.
Build tag isolation: the standalone gateway binary (KrakenD/Lura,
vendor mode, ghcr.io/hanzoai/gateway) builds with `-mod=vendor` and
must NOT pull hanzoai/cloud + hanzoai/zip into its vendor tree. The
`//go:build cloud` constraint on mount.go + mount_test.go keeps the
default build path clean. Build the cloud variant with `-tags=cloud`.
Wiring:
- init() registers ("gateway", order=80) in cloud.Registry — runs
before commerce(100) so identity headers are minted upstream of
every subsystem.
- go.mod gains the hanzoai/cloud + hanzoai/zip requires (gated by
tag at the import sites), pinned via local ../ replace.
Tests:
- TestMount_RegistersHealthAndRegistry boots a fresh zip.App, mounts
gateway with AUTH_ENABLED=false, asserts /_/gateway/healthz answers.
- cmd/gateway still builds clean with `-mod=vendor` (the standalone
KrakenD path).
Schema: schema/gateway.zap describes Health service for zapc codegen.
* refactor: collapse pkg/gateway/ → root for clean import path
Subsystem code lives in package gateway at repo root. Importers now use
`github.com/hanzoai/gateway` (no /pkg/gateway/ nesting). Standalone shim moved
to cmd/gateway/ where applicable.
Per Hanzo Go-stdlib pattern: repo IS the package.
* refactor: flatten import path — github.com/hanzoai/cloud (drop /pkg/cloud)