Skip to content

Commit 47d8e87

Browse files
committed
docs:update examples with @RequestParam(required = false).
Signed-off-by: Haotian Zhang <928016560@qq.com>
1 parent 9b70a64 commit 47d8e87

File tree

14 files changed

+85
-186
lines changed

14 files changed

+85
-186
lines changed

polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-2021-examples/pom.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,50 @@
1818
<module>quickstart-examples</module>
1919
</modules>
2020

21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-parent</artifactId>
26+
<version>2.7.18</version>
27+
<type>pom</type>
28+
<scope>import</scope>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>com.alibaba.cloud</groupId>
33+
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
34+
<version>2021.0.5.0</version>
35+
<type>pom</type>
36+
<scope>import</scope>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.springframework.cloud</groupId>
41+
<artifactId>spring-cloud-dependencies</artifactId>
42+
<version>2021.0.5</version>
43+
<type>pom</type>
44+
<scope>import</scope>
45+
</dependency>
46+
</dependencies>
47+
</dependencyManagement>
48+
49+
<build>
50+
<plugins>
51+
<plugin>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-maven-plugin</artifactId>
54+
<configuration>
55+
<executable>true</executable>
56+
</configuration>
57+
<executions>
58+
<execution>
59+
<goals>
60+
<goal>repackage</goal>
61+
</goals>
62+
</execution>
63+
</executions>
64+
</plugin>
65+
</plugins>
66+
</build>
2167
</project>

polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-2021-examples/quickstart-examples/consumer/pom.xml

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<parent>
6-
<groupId>org.springframework.boot</groupId>
7-
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.7.18</version>
9-
<relativePath/>
10-
</parent>
5+
<parent>
6+
<artifactId>2021-quickstart-examples</artifactId>
7+
<groupId>com.tencent.polaris</groupId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212

1313
<name>2021-consumer</name>
@@ -16,26 +16,6 @@
1616
<packaging>jar</packaging>
1717
<version>2.0.2.0</version>
1818

19-
<dependencyManagement>
20-
<dependencies>
21-
<dependency>
22-
<groupId>com.alibaba.cloud</groupId>
23-
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
24-
<version>2021.0.5.0</version>
25-
<type>pom</type>
26-
<scope>import</scope>
27-
</dependency>
28-
29-
<dependency>
30-
<groupId>org.springframework.cloud</groupId>
31-
<artifactId>spring-cloud-dependencies</artifactId>
32-
<version>2021.0.5</version>
33-
<type>pom</type>
34-
<scope>import</scope>
35-
</dependency>
36-
</dependencies>
37-
</dependencyManagement>
38-
3919
<dependencies>
4020
<!-- 简单的 Spring Cloud Web 依赖 -->
4121
<dependency>
@@ -75,24 +55,4 @@
7555
<artifactId>spring-boot-starter-actuator</artifactId>
7656
</dependency>
7757
</dependencies>
78-
79-
<build>
80-
<plugins>
81-
<plugin>
82-
<groupId>org.springframework.boot</groupId>
83-
<artifactId>spring-boot-maven-plugin</artifactId>
84-
<configuration>
85-
<executable>true</executable>
86-
</configuration>
87-
<executions>
88-
<execution>
89-
<goals>
90-
<goal>repackage</goal>
91-
</goals>
92-
</execution>
93-
</executions>
94-
</plugin>
95-
</plugins>
96-
</build>
97-
9858
</project>

polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-2021-examples/quickstart-examples/consumer/src/main/java/cn/polarismesh/agent/examples/alibaba/cloud/cloud/ConsumerController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public String circuitBreakRestTemplate() {
7272
@GetMapping("/echo/{str}")
7373
public ResponseEntity<String> rest(@RequestHeader Map<String, String> headerMap,
7474
@PathVariable String str,
75-
@RequestParam String param) {
75+
@RequestParam(required = false) String param) {
7676
String url = UriComponentsBuilder
7777
.fromHttpUrl("http://service-provider-2021/echo/" + str)
7878
.queryParam("param", param)
Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<parent>
4-
<groupId>org.springframework.boot</groupId>
5-
<artifactId>spring-boot-starter-parent</artifactId>
6-
<version>2.7.18</version>
7-
<relativePath/>
4+
<artifactId>2021-quickstart-examples</artifactId>
5+
<groupId>com.tencent.polaris</groupId>
6+
<version>${revision}</version>
7+
<relativePath>../pom.xml</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010
<name>2021-gateway</name>
@@ -13,26 +13,6 @@
1313
<packaging>jar</packaging>
1414
<version>2.0.2.0</version>
1515

16-
<dependencyManagement>
17-
<dependencies>
18-
<dependency>
19-
<groupId>com.alibaba.cloud</groupId>
20-
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
21-
<version>2021.0.5.0</version>
22-
<type>pom</type>
23-
<scope>import</scope>
24-
</dependency>
25-
26-
<dependency>
27-
<groupId>org.springframework.cloud</groupId>
28-
<artifactId>spring-cloud-dependencies</artifactId>
29-
<version>2021.0.5</version>
30-
<type>pom</type>
31-
<scope>import</scope>
32-
</dependency>
33-
</dependencies>
34-
</dependencyManagement>
35-
3616
<dependencies>
3717
<dependency>
3818
<groupId>org.springframework.cloud</groupId>
@@ -59,23 +39,4 @@
5939
<artifactId>spring-boot-starter-actuator</artifactId>
6040
</dependency>
6141
</dependencies>
62-
63-
<build>
64-
<plugins>
65-
<plugin>
66-
<groupId>org.springframework.boot</groupId>
67-
<artifactId>spring-boot-maven-plugin</artifactId>
68-
<configuration>
69-
<executable>true</executable>
70-
</configuration>
71-
<executions>
72-
<execution>
73-
<goals>
74-
<goal>repackage</goal>
75-
</goals>
76-
</execution>
77-
</executions>
78-
</plugin>
79-
</plugins>
80-
</build>
8142
</project>

polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-2021-examples/quickstart-examples/provider-a/pom.xml

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
6-
<groupId>org.springframework.boot</groupId>
7-
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.7.18</version>
9-
<relativePath/>
6+
<artifactId>2021-quickstart-examples</artifactId>
7+
<groupId>com.tencent.polaris</groupId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212

@@ -16,26 +16,6 @@
1616
<packaging>jar</packaging>
1717
<version>2.0.2.0</version>
1818

19-
<dependencyManagement>
20-
<dependencies>
21-
<dependency>
22-
<groupId>com.alibaba.cloud</groupId>
23-
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
24-
<version>2021.0.5.0</version>
25-
<type>pom</type>
26-
<scope>import</scope>
27-
</dependency>
28-
29-
<dependency>
30-
<groupId>org.springframework.cloud</groupId>
31-
<artifactId>spring-cloud-dependencies</artifactId>
32-
<version>2021.0.5</version>
33-
<type>pom</type>
34-
<scope>import</scope>
35-
</dependency>
36-
</dependencies>
37-
</dependencyManagement>
38-
3919
<dependencies>
4020
<!-- 使用bootstrap配置文件需要此依赖 -->
4121
<!-- <dependency>-->
@@ -74,24 +54,4 @@
7454
<artifactId>spring-boot-starter-actuator</artifactId>
7555
</dependency>
7656
</dependencies>
77-
78-
<build>
79-
<plugins>
80-
<plugin>
81-
<groupId>org.springframework.boot</groupId>
82-
<artifactId>spring-boot-maven-plugin</artifactId>
83-
<configuration>
84-
<executable>true</executable>
85-
</configuration>
86-
<executions>
87-
<execution>
88-
<goals>
89-
<goal>repackage</goal>
90-
</goals>
91-
</execution>
92-
</executions>
93-
</plugin>
94-
</plugins>
95-
</build>
96-
9757
</project>

polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-2021-examples/quickstart-examples/provider-a/src/main/java/cn/polarismesh/agent/examples/alibaba/cloud/cloud/ProviderApplication.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ public EchoController(Registration registration) {
8585
}
8686

8787
@GetMapping("/echo/{string}")
88-
public String echo(@RequestHeader Map<String, String> headerMap, @PathVariable String string, @RequestParam String param) {
88+
public String echo(@RequestHeader Map<String, String> headerMap,
89+
@PathVariable String string,
90+
@RequestParam(required = false) String param) {
8991
String result = String.format("Hello, I'm %s[%s:%s], receive msg : %s, param : %s, header : %s, my metadata : %s, name config:"
9092
+ "%s", svcName, ip, port, string, param, JacksonUtils.toJson(headerMap), JacksonUtils.toJson(registration.getMetadata()), name);
9193
LOG.info("{} -- response result: {}", svcName, result);

polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-2021-examples/quickstart-examples/provider-b/pom.xml

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
6-
<groupId>org.springframework.boot</groupId>
7-
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.7.18</version>
9-
<relativePath/>
6+
<artifactId>2021-quickstart-examples</artifactId>
7+
<groupId>com.tencent.polaris</groupId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212

@@ -16,26 +16,6 @@
1616
<packaging>jar</packaging>
1717
<version>2.0.2.0</version>
1818

19-
<dependencyManagement>
20-
<dependencies>
21-
<dependency>
22-
<groupId>com.alibaba.cloud</groupId>
23-
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
24-
<version>2021.0.5.0</version>
25-
<type>pom</type>
26-
<scope>import</scope>
27-
</dependency>
28-
29-
<dependency>
30-
<groupId>org.springframework.cloud</groupId>
31-
<artifactId>spring-cloud-dependencies</artifactId>
32-
<version>2021.0.5</version>
33-
<type>pom</type>
34-
<scope>import</scope>
35-
</dependency>
36-
</dependencies>
37-
</dependencyManagement>
38-
3919
<dependencies>
4020
<!-- 使用bootstrap配置文件需要此依赖 -->
4121
<!-- <dependency>-->
@@ -74,24 +54,4 @@
7454
<artifactId>spring-boot-starter-actuator</artifactId>
7555
</dependency>
7656
</dependencies>
77-
78-
<build>
79-
<plugins>
80-
<plugin>
81-
<groupId>org.springframework.boot</groupId>
82-
<artifactId>spring-boot-maven-plugin</artifactId>
83-
<configuration>
84-
<executable>true</executable>
85-
</configuration>
86-
<executions>
87-
<execution>
88-
<goals>
89-
<goal>repackage</goal>
90-
</goals>
91-
</execution>
92-
</executions>
93-
</plugin>
94-
</plugins>
95-
</build>
96-
9757
</project>

polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-2021-examples/quickstart-examples/provider-b/src/main/java/cn/polarismesh/agent/examples/alibaba/cloud/cloud/ProviderApplication.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ public EchoController(Registration registration) {
9191
}
9292

9393
@GetMapping("/echo/{string}")
94-
public String echo(@RequestHeader Map<String, String> headerMap, @PathVariable String string, @RequestParam String param) {
94+
public String echo(@RequestHeader Map<String, String> headerMap,
95+
@PathVariable String string,
96+
@RequestParam(required = false) String param) {
9597
String result = String.format("Hello, I'm %s[%s:%s], receive msg : %s, param : %s, header : %s, my metadata : %s, name config:"
9698
+ "%s", svcName, ip, port, string, param, JacksonUtils.toJson(headerMap), JacksonUtils.toJson(registration.getMetadata()), name);
9799
LOG.info("{} -- response result: {}", svcName, result);

polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-2022-examples/quickstart-examples/consumer/src/main/java/cn/polarismesh/agent/examples/alibaba/cloud/cloud/ConsumerController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public String circuitBreakRestTemplate() {
7272
@GetMapping("/echo/{str}")
7373
public ResponseEntity<String> rest(@RequestHeader Map<String, String> headerMap,
7474
@PathVariable String str,
75-
@RequestParam String param) {
75+
@RequestParam(required = false) String param) {
7676
String url = UriComponentsBuilder
7777
.fromHttpUrl("http://service-provider-2021/echo/" + str)
7878
.queryParam("param", param)

polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-2022-examples/quickstart-examples/provider-a/src/main/java/cn/polarismesh/agent/examples/alibaba/cloud/cloud/ProviderApplication.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public String circuitBreak() {
8686
}
8787

8888
@GetMapping("/echo/{string}")
89-
public String echo(@RequestHeader Map<String, String> headerMap, @PathVariable String string, @RequestParam String param) {
89+
public String echo(@RequestHeader Map<String, String> headerMap,
90+
@PathVariable String string,
91+
@RequestParam(required = false) String param) {
9092
String result = String.format("Hello, I'm %s[%s:%s], receive msg : %s, param : %s, header : %s, name config:"
9193
+ "%s", svcName, ip, port, string, param, JacksonUtils.toJson(headerMap), name);
9294
LOG.info("{} -- response result: {}", svcName, result);

0 commit comments

Comments
 (0)