How thejkishore/reverse-proxy-go works
This Go service is a reverse-proxy API gateway. Client requests enter the proxy handler, resolve against dynamically loaded route definitions, pass through a filter pipeline, select an upstream target, and receive the upstream response. The README documents routing, load balancing, security, resilience, transformation, tracing, audit, WebSocket, and administration capabilities. Sampled code confirms request context, upstream forwarding, route administration, and storage behavior; several filter implementations and wiring were not sampled, so those branches reflect documented capabilities without asserting internal call order.
Main entry points: filter_chain.go Filter chain · route_registry.go Route registry · main.go Gateway bootstrap · admin_handler.go Admin API
Components 29
Gateway API
- Gateway bootstrap
cmd/gateway/main.go - Proxy handler
internal/api/proxy_handler.go - Admin API
internal/api/admin_handler.go - Health endpoints
internal/api/health_handler.go - OpenAPI export
internal/api/openapi_handler.go - Audit endpoints
internal/api/audit_handler.go
Route Management
- Route registry
internal/registry/route_registry.go - Route loader
internal/registry/route_loader.go - Route matchers
internal/routing/route_matcher.go - Route definitions
internal/model/route_definition.go
Request Pipeline
- Filter chain
internal/filter/filter_chain.go - Request context
internal/filter/filter_context.go - Security filters
internal/security/jwt_auth_filter.go - Resilience filters
internal/circuitbreaker/circuit_breaker_filter.go - Response cache
internal/cache/cache_filter.go - Tracing and audit
internal/tracing/tracing_filter.go - Header and body transforms
internal/transform/transform_filter.go
Upstream Delivery
- Proxy filter
internal/proxy/proxy_filter.go - Load balancers
internal/loadbalancer/load_balancer.go - Upstream client
internal/proxy/upstream_client.go - WebSocket relay
internal/proxy/websocket_forwarder.go
Persistence
- Route storage
internal/storage/routes/route_storage.go - PostgreSQL routes
internal/storage/routes/postgres_route_storage.go - Azure Table routes
internal/storage/routes/azure_table_route_storage.go - Audit storage
internal/storage/audit/postgres_audit_storage.go
Other components
- API client
- Upstream services
- PostgreSQL
- Azure Table Storage
Connections 39
- API client → Proxy handler: sends request
- API client → Admin API: manages routes
- API client → Health endpoints: checks health
- API client → OpenAPI export: requests spec
- Gateway bootstrap → Proxy handler: wires handler
- Gateway bootstrap → Admin API: wires handler
- Gateway bootstrap → Health endpoints: wires handler
- Gateway bootstrap → Route registry: initializes
- Gateway bootstrap → Route loader: starts refresh
- Proxy handler → Route registry: resolves route
- Admin API → Route registry: updates routes
- Admin API → Route storage: persists changes
- Route loader → Route storage: loads routes
- Route loader → Route registry: refreshes routes
- Route registry → Route matchers: matches request
- Route registry → Filter chain: dispatches route
- Filter chain → Request context: shares state
- Filter chain → Security filters: runs policies
- Filter chain → Resilience filters: runs safeguards
- Filter chain → Response cache: checks cache
- Filter chain → Tracing and audit: records telemetry
- Filter chain → Header and body transforms: applies transforms
- Filter chain → Proxy filter: dispatches proxy
- Proxy filter → Load balancers: selects target
- Proxy filter → Upstream client: forwards request
- Upstream client → Upstream services: sends HTTP
- WebSocket relay → Upstream services: relays frames
- Upstream client → Request context: stores response
- Request context → Proxy handler: returns response
- OpenAPI export → Route registry: reads routes
- OpenAPI export → Upstream services: fetches specs
- Route storage → PostgreSQL routes: implemented by
- Route storage → Azure Table routes: implemented by
- PostgreSQL routes → PostgreSQL: reads and writes
- Azure Table routes → Azure Table Storage: reads and writes
- Gateway bootstrap → Audit storage: configures storage
- Tracing and audit → Audit storage: writes audit logs
- Audit endpoints → Audit storage: reads audit logs
- Audit storage → PostgreSQL: persists entries