Hey everyone,
I built an API gateway in Rust as my capstone project for Rust bootcamp and I'd appreciate a code review.
The idea is pretty standard - it sits between clients and backend services, routes requests based on config files, and handles all the reliability stuff at the gateway level so the services don't have to.
What it does:
- Reverse proxy with path parameter rewriting (
:idstyle) - Retries with exponential backoff (configurable per route)
- Circuit breaker (closed/open/half-open) so requests don't pile up on a dead service
- Token bucket rate limiting per IP
- Per-route timeouts (falls back to a global default)
- Health checks that run in the background and reject requests to unhealthy services early
- Swagger UI served from an OpenAPI spec
- Structured JSON logging
The whole thing is configured through TOML files - routes, services, timeouts, retry policies, etc. No hardcoded values. There are also two small mock services (order + payment) so you can actually run and test everything locally.
Stack: Rust, hyper, tokio, axum (for mock services only).
I'm mainly looking for feedback on:
- Overall code structure and idiomatic Rust usage
- Error handling approach (I tried to avoid
expect/unwrapeverywhere and propagate errors properly) - Anything that looks off architecturally
Any feedback is welcome, even small stuff.
Thanks!