You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spring-cloud-tencent/spring-cloud-tencent-examples/polaris-gateway-example/README-zh.md

69 lines
1.6 KiB

3 years ago
# Spring Cloud Polaris Gateway example
## 样例简介
本样例将介绍如何在Spring Cloud项目中使用```spring-cloud-tencent-polaris-gateway```以使用其各项功能。
本样例包括 ```gateway-scg-service```和```gateway-callee-service```。```gateway-scg-service```调用```gateway-callee-service```。
3 years ago
## 使用说明
### 修改配置
配置如下所示。其中,${ip}和${port}为Polaris后端服务的IP地址与端口号。
```yaml
spring:
application:
name: ${application.name}
cloud:
polaris:
address: ${ip}:${port}
```
### 启动样例
#### 启动Polaris后端服务
参考[Polaris Getting Started](https://github.com/PolarisMesh/polaris#getting-started)。
#### 启动应用
- IDEA启动
分别启动```spring-cloud-tencent-examples/polaris-gateway-example/gateway-scg-service```的```GatewayScgService```和```spring-cloud-tencent-examples/polaris-gateway-example/gateway-callee-service```的```GatewayCalleeService```
3 years ago
- Maven打包启动
在```spring-cloud-tencent-examples/polaris-gateway-example```下执行
```sh
mvn clean package
```
然后在 ```gateway-scg-service```和```gateway-callee-service```下找到生成的jar包运行
3 years ago
```
java -jar ${app.jar}
```
启动应用,其中${app.jar}替换为对应的jar包名。
### 验证
#### Spring-Cloud-Gateway调用
```shell
curl -L -X GET 'http://localhost:48083/GatewayCalleeService/gateway/example/callee/echo' -H 'SCT-CUSTOM-METADATA: {"b": 2}'
```
预期返回值
```
{"a":"1","b":2}
```
3 years ago
#### 网关限流
参考[Polaris RateLimit Example](../polaris-ratelimit-example/README-zh.md)