use of com.giffing.bucket4j.spring.boot.starter.servlet.ServletRequestFilter in project bucket4j-spring-boot-starter by MarcGiffing.
the class ServletRateLimitFilterTest method setup.
@Before
public void setup() {
consumptionProbe = Mockito.mock(ConsumptionProbe.class);
when(consumptionProbe.isConsumed()).thenReturn(true);
rateLimitCheck1 = mock(RateLimitCheck.class);
rateLimitCheck2 = mock(RateLimitCheck.class);
rateLimitCheck3 = mock(RateLimitCheck.class);
configuration = new FilterConfiguration();
configuration.setRateLimitChecks(Arrays.asList(rateLimitCheck1, rateLimitCheck2, rateLimitCheck3));
configuration.setUrl("url");
filter = new ServletRequestFilter(configuration);
}
use of com.giffing.bucket4j.spring.boot.starter.servlet.ServletRequestFilter in project bucket4j-spring-boot-starter by MarcGiffing.
the class Bucket4JAutoConfigurationServletFilter method getFilterRegistrationBean.
private FilterRegistrationBean getFilterRegistrationBean(int position) {
Integer filterCount = 0;
if (properties.getFilters().size() >= (position + 1)) {
Bucket4JConfiguration filter = properties.getFilters().get(position);
filterCount++;
FilterConfiguration filterConfig = buildFilterConfig(filter, cacheManager, servletFilterExpressionParser(), beanFactory);
servletConfigurationHolder().addFilterConfiguration(filter);
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setName("bucket4JRequestFilter" + position);
registration.setFilter(new ServletRequestFilter(filterConfig));
registration.addUrlPatterns(filter.getUrl());
registration.setOrder(filter.getFilterOrder());
log.info("create-servlet-filter;{};{};{}", position, filter.getCacheName(), filter.getUrl());
return registration;
}
return null;
}
Aggregations