diff --git a/CHANGELOG.md b/CHANGELOG.md index e4eb2719e..f40d67ed1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,3 +20,4 @@ - [refactor:refactor Polaris registration.](https://github.com/Tencent/spring-cloud-tencent/pull/1056) - [feat:added automatic optimization for dynamic config refresh type.](https://github.com/Tencent/spring-cloud-tencent/pull/1059) - [fix:fix SCG report wrong service bug when using IP routing.](https://github.com/Tencent/spring-cloud-tencent/pull/1064) +- [fix:fix gray release examples bug.](https://github.com/Tencent/spring-cloud-tencent/pull/1067) diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/FrontController.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/FrontController.java index dd777923e..d1893a694 100644 --- a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/FrontController.java +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/FrontController.java @@ -21,6 +21,7 @@ package com.tencent.cloud.polaris.router.grayrelease.front; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -39,11 +40,11 @@ public class FrontController { * @return information of callee */ @GetMapping("/rest") - public String rest() { + public String rest(@RequestHeader("uid") int user) { String env = System.getenv("SCT_METADATA_CONTENT_env"); String appName = environment.getProperty("spring.application.name"); String curName = appName + "[" + env + "]"; - String resp = routerService.rest(); + String resp = routerService.rest(user); return curName + " -> " + resp; } } diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/RouterService.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/RouterService.java index 00c7d5b9a..7afb8faa8 100644 --- a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/RouterService.java +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-frontend/src/main/java/com/tencent/cloud/polaris/router/grayrelease/front/RouterService.java @@ -20,6 +20,7 @@ package com.tencent.cloud.polaris.router.grayrelease.front; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; /** * Router callee feign client. @@ -30,6 +31,6 @@ import org.springframework.web.bind.annotation.GetMapping; public interface RouterService { @GetMapping("/router/gray/rest") - String rest(); + String rest(@RequestHeader("uid") int user); } diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/MiddleController.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/MiddleController.java index 603bf8717..c6eed8799 100644 --- a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/MiddleController.java +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/MiddleController.java @@ -21,6 +21,7 @@ package com.tencent.cloud.polaris.router.grayrelease.middle; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -39,11 +40,11 @@ public class MiddleController { * @return information of callee */ @GetMapping("/rest") - public String rest() { + public String rest(@RequestHeader("uid") int user) { String env = System.getenv("SCT_METADATA_CONTENT_env"); String appName = environment.getProperty("spring.application.name"); String curName = appName + "[" + env + "]"; - String resp = routerService.rest(); + String resp = routerService.rest(user); return curName + " -> " + resp; } } diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/RouterService.java b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/RouterService.java index 32225209c..6a9297eda 100644 --- a/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/RouterService.java +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-example/router-grayrelease-middle/src/main/java/com/tencent/cloud/polaris/router/grayrelease/middle/RouterService.java @@ -20,6 +20,7 @@ package com.tencent.cloud.polaris.router.grayrelease.middle; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; /** * Router callee feign client. @@ -30,6 +31,6 @@ import org.springframework.web.bind.annotation.GetMapping; public interface RouterService { @GetMapping("/router/gray/rest") - String rest(); + String rest(@RequestHeader("uid") int user); }