自定义路由文档

This commit is contained in:
tanghc
2019-06-14 17:26:42 +08:00
parent 4dcbc3ed01
commit 3ee105a092
6 changed files with 71 additions and 27 deletions

View File

@@ -0,0 +1,23 @@
# 自定义路由
假设有一个非java开发的接口比如php开发的接口然后需要接入到SOP使用接口名版本号进行路由跳转。
操作方式如下:
- 登录sop-admin服务管理--路由管理
- 新建一个自定义服务:`php-service`
![新建一个自定义服务](images/10086_1.png "10086_1.png")
- 选中php-service新建一个路由输入接口名、版本号、uri
![新建一个路由](images/10086_2.png "10086_2.png")
- 请求网关
`http://localhost:8081/api?method=php.goods.list&version=1.0`会跳转到`http://www.xxx.com/api/listGoods.php`
注意:
- php接口返回数据必须是json格式返回其它内容可能会调用失败
- 只有自定义服务、路由可以删除

View File

@@ -86,6 +86,8 @@ protected RequestMethod getRequestMethod() {
}
```
**建议读请求用GET写请求用POST**
### 使用方式
```java

View File

@@ -28,4 +28,22 @@ public class ZuulConfig extends AlipayZuulConfiguration {
}
}
```
```
## 注册到eureka显示hostname非ip
```yaml
eureka:
instance:
prefer-ip-address: true
instance-id: ${spring.cloud.client.ip-address}:${server.port}
```
```xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
</dependency>
```
参考https://www.jianshu.com/p/5ad8317961b7

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB