From f08d8ff35a3a5d8181fee59f5bde208912e7b301 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Thu, 27 Jul 2023 09:53:26 +0800 Subject: [PATCH] fix:fix gray release examples bug. (#1066) --- CHANGELOG.md | 1 + .../polaris/router/grayrelease/front/FrontController.java | 5 +++-- .../polaris/router/grayrelease/front/RouterService.java | 3 ++- .../polaris/router/grayrelease/middle/MiddleController.java | 5 +++-- .../polaris/router/grayrelease/middle/RouterService.java | 3 ++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c046d9d98..78351db97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,3 +20,4 @@ - [feat:added automatic optimization for dynamic config refresh type.](https://github.com/Tencent/spring-cloud-tencent/pull/1053) - [refactor:refactor Polaris registration.](https://github.com/Tencent/spring-cloud-tencent/pull/1055) - [fix:fix SCG report wrong service bug when using IP routing.](https://github.com/Tencent/spring-cloud-tencent/pull/1063) +- [fix:fix gray release examples bug.](https://github.com/Tencent/spring-cloud-tencent/pull/1066) 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); }