贴个代码:
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
log.info("==================进来了===================");
String luaScript = buildLuaScript();
ServerHttpRequest request = exchange.getRequest();
String path = request.getPath().value();
List<String> excludUrls = properties.getExcludUrls();
// 路径在不限流列表中,直接跳过
if (CollectionUtils.isNotEmpty(excludUrls) && excludUrls.contains(path)) {
return chain.filter(exchange);
}
String ip = HostUtil.getRequesHost2(request);
Thread.sleep(20000);
Number count = redissonService.executeLua(luaScript, Collections.singletonList(path+"_"+ip),
properties.getCount(), properties.getPeriod());
.....省略部分
}