rules = new HashSet<>();
+ rules.add(new GatewayFlowRule("aliyun-product-route")
+ .setCount(10)
+ .setIntervalSec(1)
+ );
+ rules.add(new GatewayFlowRule("aliyun-product-route")
+ .setCount(2)
+ .setIntervalSec(2)
+ .setBurst(2)
+ .setParamItem(new GatewayParamFlowItem()
+ .setParseStrategy(SentinelGatewayConstants.PARAM_PARSE_STRATEGY_CLIENT_IP)
+ )
+ );
+ rules.add(new GatewayFlowRule("another-route-httpbin")
+ .setCount(10)
+ .setIntervalSec(1)
+ .setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER)
+ .setMaxQueueingTimeoutMs(600)
+ .setParamItem(new GatewayParamFlowItem()
+ .setParseStrategy(SentinelGatewayConstants.PARAM_PARSE_STRATEGY_HEADER)
+ .setFieldName("X-Sentinel-Flag")
+ )
+ );
+ rules.add(new GatewayFlowRule("another-route-httpbin")
+ .setCount(1)
+ .setIntervalSec(1)
+ .setParamItem(new GatewayParamFlowItem()
+ .setParseStrategy(SentinelGatewayConstants.PARAM_PARSE_STRATEGY_URL_PARAM)
+ .setFieldName("pa")
+ )
+ );
+
+ rules.add(new GatewayFlowRule("some_customized_api")
+ .setResourceMode(SentinelGatewayConstants.RESOURCE_MODE_CUSTOM_API_NAME)
+ .setCount(5)
+ .setIntervalSec(1)
+ .setParamItem(new GatewayParamFlowItem()
+ .setParseStrategy(SentinelGatewayConstants.PARAM_PARSE_STRATEGY_URL_PARAM)
+ .setFieldName("pn")
+ )
+ );
+ GatewayRuleManager.loadRules(rules);
+ }
+}
diff --git a/sentinel-demo/sentinel-demo-zuul-gateway/src/main/java/com/alibaba/csp/sentinel/demo/zuul/gateway/ZuulConfig.java b/sentinel-demo/sentinel-demo-zuul-gateway/src/main/java/com/alibaba/csp/sentinel/demo/zuul/gateway/ZuulConfig.java
new file mode 100644
index 00000000..84d03e1e
--- /dev/null
+++ b/sentinel-demo/sentinel-demo-zuul-gateway/src/main/java/com/alibaba/csp/sentinel/demo/zuul/gateway/ZuulConfig.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 1999-2019 Alibaba Group Holding Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.csp.sentinel.demo.zuul.gateway;
+
+import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulErrorFilter;
+import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulPostFilter;
+import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulPreFilter;
+
+import com.netflix.zuul.ZuulFilter;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author Eric Zhao
+ */
+@Configuration
+public class ZuulConfig {
+
+ @Bean
+ public ZuulFilter sentinelZuulPreFilter() {
+ return new SentinelZuulPreFilter(10000);
+ }
+
+ @Bean
+ public ZuulFilter sentinelZuulPostFilter() {
+ return new SentinelZuulPostFilter(1000);
+ }
+
+ @Bean
+ public ZuulFilter sentinelZuulErrorFilter() {
+ return new SentinelZuulErrorFilter(-1);
+ }
+}
diff --git a/sentinel-demo/sentinel-demo-zuul-gateway/src/main/java/com/alibaba/csp/sentinel/demo/zuul/gateway/ZuulGatewayDemoApplication.java b/sentinel-demo/sentinel-demo-zuul-gateway/src/main/java/com/alibaba/csp/sentinel/demo/zuul/gateway/ZuulGatewayDemoApplication.java
new file mode 100644
index 00000000..3b5f51ca
--- /dev/null
+++ b/sentinel-demo/sentinel-demo-zuul-gateway/src/main/java/com/alibaba/csp/sentinel/demo/zuul/gateway/ZuulGatewayDemoApplication.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1999-2019 Alibaba Group Holding Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.csp.sentinel.demo.zuul.gateway;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
+
+/**
+ * A demo for using Zuul 1.x with Spring Cloud and Sentinel.
+ *
+ * To integrate with Sentinel dashboard, you can run the demo with the parameters (an example):
+ *
+ * -Dproject.name=zuul-gateway -Dcsp.sentinel.dashboard.server=localhost:8080
+ * -Dcsp.sentinel.api.port=8720 -Dcsp.sentinel.app.type=1
+ *
+ *
+ *
+ * @author Eric Zhao
+ */
+@SpringBootApplication
+@EnableZuulProxy
+public class ZuulGatewayDemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ZuulGatewayDemoApplication.class, args);
+ }
+}
diff --git a/sentinel-demo/sentinel-demo-zuul-gateway/src/main/resources/application.yml b/sentinel-demo/sentinel-demo-zuul-gateway/src/main/resources/application.yml
new file mode 100644
index 00000000..296d5083
--- /dev/null
+++ b/sentinel-demo/sentinel-demo-zuul-gateway/src/main/resources/application.yml
@@ -0,0 +1,13 @@
+server:
+ port: 8097
+spring:
+ application:
+ name: zuul-gateway
+zuul:
+ routes:
+ aliyun-product-route:
+ path: /aliyun_product/**
+ url: https://www.aliyun.com/product
+ another-route-httpbin:
+ path: /another/**
+ url: https://httpbin.org
\ No newline at end of file