Skip to content

icetimux/api-gateway

Repository files navigation

api-gateway

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.


What this is

  • 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

What I'm learning

  • How net/http and httputil.ReverseProxy work 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

Running it

# Local
go build -o api-gateway && ./api-gateway config.yaml

# Docker Compose
docker compose up --build

# Test
bash test.sh

See docs/REFERENCE.md for full configuration, architecture notes, API reference, and deployment details.

About

API gateway with JWT authentication, configurable middleware, and intelligent upstream routing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors