提交 4e01c651 编写于 作者: G Gadfly

fix: 布隆过滤器放行不匹配的路径

上级 a4caa73d
......@@ -18,7 +18,8 @@ public class InterceptorConfiguration implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) {
//注册拦截器
registry.addInterceptor(bloomInterceptorHandler())
.addPathPatterns("/app-api/v1/goods/**");
.addPathPatterns("/app-api/v1/goods/**")
.excludePathPatterns("/app-api/v1/goods/sku/**");
}
@Bean
......
......@@ -32,7 +32,13 @@ public class BloomFilterInterceptor implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String currentUrl = request.getRequestURI();
PathMatcher matcher = new AntPathMatcher();
Map<String, String> pathVariable = matcher.extractUriTemplateVariables("/app-api/v1/goods/{id}", currentUrl);
Map<String, String> pathVariable;
try {
pathVariable = matcher.extractUriTemplateVariables("/app-api/v1/goods/{id}", currentUrl);
} catch (IllegalStateException e) {
// 路径不匹配则放行
return true;
}
if (bloomRedisService.includeByBloomFilter(PmsConstants.PRODUCT_REDIS_BLOOM_FILTER, pathVariable.get("id"))) {
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册