1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

Modify nacos-discovery-example to test UrlCleaner of

`SentinelResttemplate`
This commit is contained in:
Rivers-Shall 2019-08-19 16:02:01 +08:00
parent 44f073cdb4
commit 57ec776c7b
2 changed files with 13 additions and 0 deletions

View File

@ -26,6 +26,7 @@ public class ConsumerApplication {
@LoadBalanced
@Bean
@SentinelRestTemplate(urlCleanerClass = UrlCleaner.class, urlCleaner = "clean")
public RestTemplate restTemplate() {
return new RestTemplate();
}

View File

@ -0,0 +1,12 @@
package com.alibaba.cloud.examples;
public class UrlCleaner {
public static String clean(String url) {
System.out.println("enter urlCleaner");
if (url.matches(".*/echo/.*")) {
System.out.println("change url");
url = url.replaceAll("/echo/.*", "/echo/{str}");
}
return url;
}
}