2026-08-27 11:36:13 -07:00
|
|
|
# 8.2 — `X-Service`/`X-Resource` dispatcher (GREEN)
|
2026-08-26 13:47:36 -07:00
|
|
|
|
|
|
|
|
Phase: 8 — ServiceAdapter CRD rollout
|
2026-08-27 11:36:13 -07:00
|
|
|
Stage: GREEN ✅
|
|
|
|
|
Depends on: 8.1 (CRD, in-memory registry)
|
2026-08-26 13:47:36 -07:00
|
|
|
|
|
|
|
|
Design contract: [API_ROUTING_HYBRID_DESIGN.md](../API_ROUTING_HYBRID_DESIGN.md) §2, §4.
|
|
|
|
|
|
2026-08-27 11:36:13 -07:00
|
|
|
- [x] `internal/server/router.go` X-Service branch before path routing
|
|
|
|
|
- [x] Path-based routes (`/v1/chat/completions`, etc.) unchanged
|
|
|
|
|
- [x] X-Service + X-Resource dispatch to adapter methods
|
|
|
|
|
- [x] 404 for unknown services/resources
|
|
|
|
|
- [x] Auth stub (SQS requires header, others pass-through)
|
|
|
|
|
- [x] HTTP proxying with path rewriting
|
|
|
|
|
- [x] gRPC detection (Temporal, Phase 9)
|
|
|
|
|
- [x] Real integration tests
|
2026-08-26 13:47:36 -07:00
|
|
|
|
2026-08-27 11:36:13 -07:00
|
|
|
**Future (not Phase 8.2):**
|
|
|
|
|
- [ ] Blind 5xx retry with backoff (scope: internal/resilience)
|
|
|
|
|
- [ ] {id} path parameter resolution (scope: API design)
|
|
|
|
|
- [ ] Phase 3: JWT signature validation vs Authentik JWKS
|
|
|
|
|
|
|
|
|
|
## Verification (Done)
|
2026-08-26 13:47:36 -07:00
|
|
|
|
|
|
|
|
```bash
|
2026-08-27 11:36:13 -07:00
|
|
|
# ✅ Unknown service → 404
|
|
|
|
|
curl -H 'X-Service: nonexistent' https://api.riotpiao.com/
|
|
|
|
|
# {"type":"about:blank#not-found","detail":"service 'nonexistent' not found"}
|
2026-08-26 13:47:36 -07:00
|
|
|
|
2026-08-27 11:36:13 -07:00
|
|
|
# ✅ Known service, unknown resource → 404
|
|
|
|
|
curl -H 'X-Service: sqs' -H 'X-Resource: invalid' https://api.riotpiao.com/
|
|
|
|
|
# {"type":"about:blank#not-found","detail":"resource 'invalid' not found"}
|
2026-08-26 13:47:36 -07:00
|
|
|
|
2026-08-27 11:36:13 -07:00
|
|
|
# ✅ Authorization header pass-through (MinIO, Temporal, Memory, IAM)
|
|
|
|
|
curl -H 'X-Service: s3' -H 'Authorization: Bearer token' https://api.riotpiao.com/
|
|
|
|
|
# Requests proxied with header intact
|
2026-08-26 13:47:36 -07:00
|
|
|
|
2026-08-27 11:36:13 -07:00
|
|
|
# ✅ SQS requires auth header
|
|
|
|
|
curl -H 'X-Service: sqs' https://api.riotpiao.com/
|
|
|
|
|
# {"type":"about:blank#forbidden","detail":"SQS requires Authorization header"}
|
|
|
|
|
|
|
|
|
|
# ✅ Real integration tests
|
|
|
|
|
GATEWAY_URL=https://api.riotpiao.com go test -tags integration -v ./internal/serviceadapter
|
2026-08-26 13:47:36 -07:00
|
|
|
```
|
2026-08-27 11:36:13 -07:00
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
|
|
|
|
|
- Router moved to dumb pipe (Option B): services validate JWTs independently
|
|
|
|
|
- SQS special case: Gateway checks header (code unverified, Phase 3 will validate signature)
|
|
|
|
|
- MinIO, Temporal: Native JWT support (dumb pipe pass-through)
|
|
|
|
|
- ConfigMap-based config, Stakater Reloader auto-restarts on changes
|
|
|
|
|
- 5 adapters: sqs, workflow (gRPC), memory, s3, iam
|