Skip to content

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: true

2. 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

PropertyDefaultDescription
apigen.gateway.enabledfalseEnable gateway
apigen.gateway.auth.enabledtrueEnable authentication filter
apigen.gateway.rate-limit.enabledtrueEnable rate limiting
apigen.gateway.circuit-breaker.enabledtrueEnable circuit breaker
apigen.gateway.cors.enabledtrueEnable CORS

Released under the MIT License.