feat: add spring cloud gateway mvc example (#1367)

pull/1408/head
Fishtail 4 months ago committed by GitHub
parent 549f34fb80
commit 42b7c7a0ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -16,3 +16,4 @@
- [fix:fix no registry when lossless is disabled.](https://github.com/Tencent/spring-cloud-tencent/pull/1312)
- [fix:fix the ratelimit bug for 2023](https://github.com/Tencent/spring-cloud-tencent/pull/1316)
- [fix:update spring boot version](https://github.com/Tencent/spring-cloud-tencent/pull/1333)
- [feat:add scg-mvc example](https://github.com/Tencent/spring-cloud-tencent/pull/1367)

@ -19,5 +19,6 @@
<module>quickstart-caller-service</module>
<module>quickstart-callee-service-a</module>
<module>quickstart-callee-service-b</module>
<module>quickstart-gateway-mvc-service</module>
</modules>
</project>

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quickstart-example</artifactId>
<groupId>com.tencent.cloud</groupId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>quickstart-gateway-mvc-service</artifactId>
<name>Quickstart Gateway MVC Service</name>
<dependencies>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway-mvc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,37 @@
/*
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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.tencent.cloud.quickstart.gatewaymvc;
import reactor.core.publisher.Mono;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* FallbackController.
*
* sean yu
*/
@RestController
public class FallbackController {
@GetMapping("/polaris-fallback")
Mono<String> getFallback() {
return Mono.just("fallback: trigger the refuse for service caller.");
}
}

@ -0,0 +1,35 @@
/*
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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.tencent.cloud.quickstart.gatewaymvc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Quickstart SCG application.
*
* @author Haotian Zhang
*/
@SpringBootApplication
public class QuickstartGatewayMvcApplication {
public static void main(String[] args) {
SpringApplication.run(QuickstartGatewayMvcApplication.class, args);
}
}

@ -0,0 +1,30 @@
server:
port: 48085
spring:
application:
name: QuickStartGatewayMvcService
config:
import: optional:polaris
cloud:
polaris:
address: grpc://119.91.66.223:8091
namespace: default
enabled: true
contract:
exposure: true
report:
enabled: true
stat:
enabled: true
port: 28085
gateway:
mvc:
routes:
- id: QuickstartCallerService
uri: lb://QuickstartCallerService
predicates:
- Path=/QuickstartCallerService/**
filters:
- StripPrefix=1
Loading…
Cancel
Save