RustGate is a high-performance, secure, and extensible API gateway written in Rust, using Axum, Tower. It routes HTTP traffic to microservices with built-in support for JWT authentication, Prometheus metrics, and dynamic service configuration.
- 🔁 Reverse proxy with dynamic path-based routing via
/api/{service}/{path..} - 🔐 JWT-based authentication middleware (optional with
Authorizationheader) - 📊 Prometheus-compatible metrics exposed at
/metrics - ⚙️ Configuration via
TOML(config/config.toml) - 🧩 Built with async Rust (Tokio + Hyper 1.6)
- 🧪 Developer-friendly tooling with
just
- Rust 1.76+
just(optional, for task automation)- Docker (optional, for microservice mocks or full stack)
Create a config/config.toml:
[server]
address = "0.0.0.0"
port = 8080
[services]
users = "http://localhost:8001"
payments = "http://localhost:8002"Each incoming request like:
GET /api/users/profile
Will be proxied to:
GET http://localhost:8001/profile
cargo runYou should see:
📊 Metrics server listening on http://0.0.0.0:9090
🚀 RustGate listening on http://0.0.0.0:8080
By default, all routes under /api/* require a valid JWT:
curl -H "Authorization: Bearer <your_jwt>" http://localhost:8080/api/users/testTo disable auth temporarily, comment out jwt_auth middleware in router.rs.
Visit:
http://localhost:9090/metricsTo see Prometheus-compatible metrics.
Install just:
cargo install justjust build # Build the Rust project
just run # Run gateway locally
just docker-build # Build the Docker image
just docker-run # Run container with config mounted
just compose-up # Start services with Docker ComposePRs and feedback welcome! Feel free to open issues or suggestions.