mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
自定义路由文档
This commit is contained in:
23
doc/docs/files/10086_自定义路由.md
Normal file
23
doc/docs/files/10086_自定义路由.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# 自定义路由
|
||||
|
||||
假设有一个非java开发的接口,比如php开发的接口,然后需要接入到SOP,使用接口名版本号进行路由跳转。
|
||||
|
||||
操作方式如下:
|
||||
|
||||
- 登录sop-admin,服务管理--路由管理
|
||||
- 新建一个自定义服务:`php-service`
|
||||
|
||||

|
||||
|
||||
- 选中php-service,新建一个路由,输入接口名、版本号、uri
|
||||
|
||||

|
||||
|
||||
- 请求网关
|
||||
|
||||
`http://localhost:8081/api?method=php.goods.list&version=1.0`会跳转到`http://www.xxx.com/api/listGoods.php`
|
||||
|
||||
注意:
|
||||
|
||||
- php接口返回数据必须是json格式,返回其它内容可能会调用失败
|
||||
- 只有自定义服务、路由可以删除
|
@@ -86,6 +86,8 @@ protected RequestMethod getRequestMethod() {
|
||||
}
|
||||
```
|
||||
|
||||
**建议读请求用GET,写请求用POST**,
|
||||
|
||||
### 使用方式
|
||||
|
||||
```java
|
||||
|
@@ -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
|
||||
|
BIN
doc/docs/files/images/10086_1.png
Normal file
BIN
doc/docs/files/images/10086_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
BIN
doc/docs/files/images/10086_2.png
Normal file
BIN
doc/docs/files/images/10086_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
Reference in New Issue
Block a user