Skip to content

Commit

Permalink
bumped versions, removed support for Zuul (#79)
Browse files Browse the repository at this point in the history
* bumped versions, removed support for Zuul

* Update pom.xml

* Update pom.xml

* Update pom.xml

* Update pom.xml

* Update pom.xml

Co-authored-by: MarcGiffing <[email protected]>
  • Loading branch information
bobs-bits and MarcGiffing authored Apr 5, 2021
1 parent a081650 commit e3c060f
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 370 deletions.
10 changes: 4 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ https://github.com/MarcGiffing/bucket4j-spring-boot-starter-examples[bucket4j-sp
* https://github.com/MarcGiffing/bucket4j-spring-boot-starter-examples/tree/master/bucket4j-spring-boot-starter-example-ehcache[Ehcache]
* https://github.com/MarcGiffing/bucket4j-spring-boot-starter-examples/tree/master/bucket4j-spring-boot-starter-example-hazelcast[Hazelcast]
* https://github.com/MarcGiffing/bucket4j-spring-boot-starter-examples/tree/master/bucket4j-spring-boot-starter-example-caffeine[Caffeine]
* https://github.com/MarcGiffing/bucket4j-spring-boot-starter-examples/tree/master/bucket4j-spring-boot-starter-example-zuul[Zuul]
* https://github.com/MarcGiffing/bucket4j-spring-boot-starter-examples/tree/master/bucket4j-spring-boot-starter-example-webflux[Webflux (Async)]

= Contents
Expand Down Expand Up @@ -108,7 +107,7 @@ spring:
----
bucket4j.enabled=true # enable/disable bucket4j support
bucket4j.filters[0].cache-name=buckets # the name of the cache key
bucket4j.filters[0].filter-method=servlet # [servlet,zuul,webflux,gateway]
bucket4j.filters[0].filter-method=servlet # [servlet,webflux,gateway]
bucket4j.filters[0].filter-order= # Per default the lowest integer plus 10. Set it to a number higher then zero to execute it after e.g. Spring Security.
bucket4j.filters[0].http-response-body={ "message": "Too many requests" } # the json response which should be added to the body
bucket4j.filters[0].http-response-headers.<MY_CUSTOM_HEADER>=MY_CUSTOM_HEADER_VALUE # You can add any numbers of custom headers
Expand Down Expand Up @@ -150,10 +149,9 @@ The IP filter type limits the access based on the IP address (httpServletRequest
The expression based filter type provides the most flexible one and uses the https://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html[Spring Expression Language] (SpEL). https://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html#expressions-spel-compilation[The expression compiles to a Java class which will be used].
It provides an easy way to configure the throttling in different environments without writing one line of code.

Depending on the filter method [servlet,zuul,webflux,gateway] different SpEL root objects object can be used in the expression so that you have a direct access to the method of these request objects:
Depending on the filter method [servlet,webflux,gateway] different SpEL root objects object can be used in the expression so that you have a direct access to the method of these request objects:

* servlet: javax.servlet.http.HttpServletRequest (e.g. getRemoteAddr() or getRequestURI())
* zuul: javax.servlet.http.HttpServletRequest
* webflux: org.springframework.http.server.reactive.ServerHttpRequest
* gateway: org.springframework.http.server.reactive.ServerHttpRequest

Expand Down Expand Up @@ -289,13 +287,13 @@ bucket4j:
unit: minutes
----

Configuration of multiple independently filters (servlet filter or zuul) with specific rate limit configurations.
Configuration of multiple independently filters (servlet|gateway|webflux filters) with specific rate limit configurations.

[source,yml]
----
bucket4j:
enabled: true
filters: # each config entry creates one servlet filter or zuul filter
filters: # each config entry creates one servlet filter or other filter
- cache-name: buckets # create new servlet filter with bucket4j configuration
url: /admin*
rate-limits:
Expand Down
5 changes: 2 additions & 3 deletions bucket4j-spring-boot-starter-context/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.giffing.bucket4j.spring.boot.starter</groupId>
<artifactId>bucket4j-spring-boot-starter-parent</artifactId>
<version>${revision}</version>
<version>${revision}</version>
</parent>
<artifactId>bucket4j-spring-boot-starter-context</artifactId>

Expand All @@ -29,5 +29,4 @@
<optional>true</optional>
</dependency>
</dependencies>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ public enum FilterMethod {
*/
SERVLET,

/**
* ZuulRoute filter
*/
ZUUL,

/**
* Spring Boots 5 async WebFilter
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


/**
* Used to check if the rate limit should be performed independently from the Servlet Filter or ZuulFilter.
* Used to check if the rate limit should be performed independently from the servlet|webflux|gateway request filter
*
*/
@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.giffing.bucket4j.spring.boot.starter.context.RateLimitConditionMatchingStrategy;

/**
* This class is the main configuration class which is used to build the Servlet Filter or ZuulFilter.
* This class is the main configuration class which is used to build the servlet|webflux|gateway request filter
*
*/
public class FilterConfiguration<R> {
Expand Down
17 changes: 11 additions & 6 deletions bucket4j-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.giffing.bucket4j.spring.boot.starter</groupId>
<artifactId>bucket4j-spring-boot-starter-parent</artifactId>
<version>${revision}</version>
<version>${revision}</version>
<relativePath>..</relativePath>
</parent>

Expand Down Expand Up @@ -38,11 +38,6 @@
<artifactId>spring-boot-starter-webflux</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
Expand All @@ -57,6 +52,16 @@
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.springframework.util.StringUtils;

import com.giffing.bucket4j.spring.boot.starter.config.servlet.Bucket4JAutoConfigurationServletFilter;
import com.giffing.bucket4j.spring.boot.starter.config.zuul.Bucket4JAutoConfigurationZuul;
import com.giffing.bucket4j.spring.boot.starter.context.Condition;
import com.giffing.bucket4j.spring.boot.starter.context.ConsumptionProbeHolder;
import com.giffing.bucket4j.spring.boot.starter.context.KeyFilter;
Expand All @@ -43,8 +42,11 @@
import io.github.bucket4j.grid.ProxyManager;

/**
* Holds helper Methods which are reused by the {@link Bucket4JAutoConfigurationServletFilter} and
* the {@link Bucket4JAutoConfigurationZuul} configuration classes
* Holds helper Methods which are reused by the
* {@link Bucket4JAutoConfigurationServletFilter}
* {@link Bucket4JAutoConfigurationSpringCloudGatewayFilter}
* {@link Bucket4JAutoConfigurationWebfluxFilter}
* configuration classes
*/
public abstract class Bucket4JBaseConfiguration<R> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import com.giffing.bucket4j.spring.boot.starter.config.cache.AsyncCacheResolver;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.map.IMap;

import io.github.bucket4j.Bucket4j;
import io.github.bucket4j.grid.GridBucketState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ public static class Bucket4jEndpointConfig {
@Qualifier("SERVLET")
private Bucket4jConfigurationHolder servletConfigs;

@Autowired(required = false)
@Qualifier("ZUUL")
private Bucket4jConfigurationHolder zuulConfigs;

@Autowired(required = false)
@Qualifier("WEBFLUX")
private Bucket4jConfigurationHolder webfluxConfigs;
Expand All @@ -39,9 +35,6 @@ public Map<String, Object> bucket4jConfig() {
if(servletConfigs != null) {
result.put("servlet", servletConfigs.getFilterConfiguration());
}
if(zuulConfigs != null) {
result.put("zuul", zuulConfigs.getFilterConfiguration());
}
if(webfluxConfigs != null) {
result.put("webflux", webfluxConfigs.getFilterConfiguration());
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import com.giffing.bucket4j.spring.boot.starter.context.RateLimitConditionMatchingStrategy;
import com.giffing.bucket4j.spring.boot.starter.context.properties.FilterConfiguration;
import com.giffing.bucket4j.spring.boot.starter.filter.reactive.ReactiveRateLimitException;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

import io.github.bucket4j.ConsumptionProbe;
import reactor.core.publisher.Mono;
Expand Down
Loading

0 comments on commit e3c060f

Please sign in to comment.