APiGen Gateway Module
API Gateway with Spring Cloud Gateway for APiGen applications.
Features
- Global Filters: Logging, Authentication, Rate Limiting, Request Timing
- Dynamic Routes: Runtime route configuration without restart
- Circuit Breaker: Resilience4j integration with timeout and fallback
- CORS Support: Configurable cross-origin resource sharing
- Metrics: Micrometer integration for Prometheus/Grafana
Quick Start
1. Enable Gateway
yaml
apigen:
gateway:
enabled: true
auth:
enabled: true
rate-limit:
enabled: true
circuit-breaker:
enabled: true2. Configure Routes
java
@Configuration
public class GatewayRoutesConfig {
@Bean
public RouteLocator customRoutes(RouteLocatorBuilder builder) {
return builder.routes()
.route("user-service", r -> r
.path("/api/users/**")
.filters(f -> f.stripPrefix(1))
.uri("http://user-service:8080"))
.build();
}
}Architecture
Configuration Properties
| Property | Default | Description |
|---|---|---|
apigen.gateway.enabled | false | Enable gateway |
apigen.gateway.auth.enabled | true | Enable authentication filter |
apigen.gateway.rate-limit.enabled | true | Enable rate limiting |
apigen.gateway.circuit-breaker.enabled | true | Enable circuit breaker |
apigen.gateway.cors.enabled | true | Enable CORS |