[Feature] Integration with Spring Cloud Gateway
Issue Description
Integration with Spring Cloud Gateway
Describe what happened (or what feature you want)
In my recent tests, Spring Cloud Gateway is a bit better than Zuul&Zuul2 Gateway. Community can Integrate it.
refer: https://github.com/spring-cloud/spring-cloud-gateway/blob/86489b6d7747aee3ff72b5bbdeb81a07a1ab489e/spring-cloud-gateway-sample/src/main/java/org/springframework/cloud/gateway/sample/ThrottleGatewayFilter.java
大神,钉钉搞个专项的群呀,组织下,正好有这方面的需求
大神,钉钉搞个专项的群呀,组织下,正好有这方面的需求
和你的钉钉账号联系不起来。你能在首页的钉钉群里联系一下"宿何"吗?
Contributions are welcomed :)
you can FYI this code and i has implements spring-cloud- gateway for sentinel by gatewayfilter `@Component public class SentinelGatewayFilter implements GlobalFilter, Ordered {
@Override
public int getOrder() {
// TODO Auto-generated method stub
return -1;
}
@Override
public Mono<Void> filter(ServerWebExchange serverWebExchange, GatewayFilterChain chain) {
String resource = serverWebExchange.getRequest().getPath().toString();
this.initFlowRules(resource);
Entry entry = null;
try {
ContextUtil.enter(resource);
entry = SphU.entry(resource, EntryType.IN, 1, serverWebExchange.getRequest().getQueryParams().values());
return chain.filter(serverWebExchange);
} catch (BlockException e) {
if (!BlockException.isBlockException(e)) {
Tracer.trace(e);
}
e.printStackTrace();
} finally {
if (entry != null) {
entry.exit();
}
ContextUtil.exit();
}
serverWebExchange.getResponse().setStatusCode(HttpStatus.TOO_MANY_REQUESTS);
return serverWebExchange.getResponse().setComplete();
}
private void initFlowRules(final String resource){
List<FlowRule> rules = new ArrayList<FlowRule>();
// 限流
FlowRule rule = new FlowRule();
rule.setResource(resource);
rule.setCount(5);
rule.setGrade(RuleConstant.FLOW_GRADE_QPS);
rule.setLimitApp("default");
rules.add(rule);
FlowRuleManager.loadRules(rules);
}
} `
management.endpoints.web.exposure.include=*
#Sentinel 控制台地址
spring.cloud.sentinel.transport.dashboard=localhost:8080
#取消Sentinel控制台懒加载
spring.cloud.sentinel.eager=true
Because sentinel need to support by servlet, but the spring-cloud-gateway does't need servlet. so ,you can import servlet dependency into your pom.xml
This is the current way, or look forward to the sentinel support for spring cloud gateway.
Hi folks, since 1.5.0 Sentinel has provided integration module for Reactor and Spring WebFlux. If you're interested in contributing this feature, you can refer to the two modules :)
This will be supported in 1.6.0. See #695 for details.