A personal project to learn and explore networking and backend programming in Go.
The goal is to build a real, working API gateway from scratch — not to use a framework, not to take shortcuts — and actually understand how things work along the way: how reverse proxying works, how connection pooling is managed, how to handle retries and timeouts correctly, JWT auth, rate limiting, graceful shutdown, etc.
- A reverse proxy / API gateway written in Go using only the standard library (plus a few small packages)
- Routes incoming HTTP requests to backend microservices based on path prefix or exact match
- Includes middleware for logging, rate limiting, JWT auth, and CORS
- Health checks for the gateway itself and upstream services
- Configurable per-route timeouts, retries, and auth requirements
- Graceful shutdown on SIGINT/SIGTERM
- How
net/httpandhttputil.ReverseProxywork under the hood - Connection pooling and transport configuration
- Middleware chaining patterns
- JWT validation without a big auth library
- Per-IP rate limiting with in-memory state
- Retry logic with exponential backoff
- Graceful shutdown with in-flight request draining
- Structuring a Go project without over-engineering it
# Local
go build -o api-gateway && ./api-gateway config.yaml
# Docker Compose
docker compose up --build
# Test
bash test.shSee docs/REFERENCE.md for full configuration, architecture notes, API reference, and deployment details.