tanghc 4 years ago
parent a68ac1a10c
commit ee30f18d53
  1. 74
      doc/docs/_sidebar.md
  2. 42
      doc/docs/files/10011_项目接入到SOP.md
  3. 8
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java
  4. 4
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java
  5. 11
      sop-example/sop-story/src/main/resources/application-dev.properties

@ -1,39 +1,39 @@
* [首页](/?t=1591927043815) * [首页](/?t=1595832340981)
* 开发文档 * 开发文档
* [快速体验](files/10010_快速体验.md?t=1591927043817) * [快速体验](files/10010_快速体验.md?t=1595832340983)
* [项目接入到SOP](files/10011_项目接入到SOP.md?t=1591927043835) * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1595832341000)
* [新增接口](files/10020_新增接口.md?t=1591927043836) * [新增接口](files/10020_新增接口.md?t=1595832341000)
* [开发流程](files/10021_开发流程.md?t=1591927043836) * [开发流程](files/10021_开发流程.md?t=1595832341001)
* [业务参数校验](files/10030_业务参数校验.md?t=1591927043836) * [业务参数校验](files/10030_业务参数校验.md?t=1595832341001)
* [错误处理](files/10040_错误处理.md?t=1591927043836) * [错误处理](files/10040_错误处理.md?t=1595832341001)
* [编写文档](files/10041_编写文档.md?t=1591927043836) * [编写文档](files/10041_编写文档.md?t=1595832341001)
* [接口交互详解](files/10050_接口交互详解.md?t=1591927043836) * [接口交互详解](files/10050_接口交互详解.md?t=1595832341001)
* [easyopen支持](files/10070_easyopen支持.md?t=1591927043836) * [easyopen支持](files/10070_easyopen支持.md?t=1595832341001)
* [使用签名校验工具](files/10080_使用签名校验工具.md?t=1591927043836) * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1595832341001)
* [ISV管理](files/10085_ISV管理.md?t=1591927043836) * [ISV管理](files/10085_ISV管理.md?t=1595832341001)
* [自定义返回结果](files/10087_自定义返回结果.md?t=1591927043837) * [自定义返回结果](files/10087_自定义返回结果.md?t=1595832341001)
* [自定义过滤器](files/10088_自定义过滤器.md?t=1591927043837) * [自定义过滤器](files/10088_自定义过滤器.md?t=1595832341001)
* [自定义校验token](files/10089_自定义校验token.md?t=1591927043837) * [自定义校验token](files/10089_自定义校验token.md?t=1595832341002)
* [网关拦截器](files/10090_网关拦截器.md?t=1591927043837) * [网关拦截器](files/10090_网关拦截器.md?t=1595832341002)
* [路由授权](files/10090_路由授权.md?t=1591927043837) * [路由授权](files/10090_路由授权.md?t=1595832341002)
* [接口限流](files/10092_接口限流.md?t=1591927043837) * [接口限流](files/10092_接口限流.md?t=1595832341002)
* [路由监控](files/10093_路由监控.md?t=1591927043837) * [路由监控](files/10093_路由监控.md?t=1595832341002)
* [SDK开发](files/10095_SDK开发.md?t=1591927043837) * [SDK开发](files/10095_SDK开发.md?t=1595832341002)
* [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1591927043837) * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1595832341002)
* [应用授权](files/10097_应用授权.md?t=1591927043837) * [应用授权](files/10097_应用授权.md?t=1595832341003)
* [提供restful接口](files/10100_提供restful接口.md?t=1591927043838) * [提供restful接口](files/10100_提供restful接口.md?t=1595832341003)
* [文件上传](files/10104_文件上传.md?t=1591927043838) * [文件上传](files/10104_文件上传.md?t=1595832341003)
* [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1591927043838) * [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1595832341003)
* [预发布灰度发布](files/10110_预发布灰度发布.md?t=1591927043838) * [预发布灰度发布](files/10110_预发布灰度发布.md?t=1595832341003)
* [动态修改请求参数](files/10111_动态修改请求参数.md?t=1591927043838) * [动态修改请求参数](files/10111_动态修改请求参数.md?t=1595832341003)
* [使用eureka](files/10112_使用eureka.md?t=1591927043838) * [使用eureka](files/10112_使用eureka.md?t=1595832341003)
* [扩展其它注册中心](files/10113_扩展其它注册中心.md?t=1591927043838) * [扩展其它注册中心](files/10113_扩展其它注册中心.md?t=1595832341003)
* 原理分析 * 原理分析
* [网关性能测试](files/90001_网关性能测试.md?t=1591927043838) * [网关性能测试](files/90001_网关性能测试.md?t=1595832341004)
* [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1591927043838) * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1595832341004)
* [原理分析之如何存储路由](files/90011_原理分析之如何存储路由.md?t=1591927043838) * [原理分析之如何存储路由](files/90011_原理分析之如何存储路由.md?t=1595832341004)
* [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1591927043839) * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1595832341004)
* [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1591927043839) * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1595832341004)
* [原理分析之预发布灰度发布](files/90014_原理分析之预发布灰度发布.md?t=1591927043839) * [原理分析之预发布灰度发布](files/90014_原理分析之预发布灰度发布.md?t=1595832341004)
* [2.x升3.x注意事项](files/90099_2.x升3.x注意事项.md?t=1591927043839) * [2.x升3.x注意事项](files/90099_2.x升3.x注意事项.md?t=1595832341004)
* [常见问题](files/90100_常见问题.md?t=1591927043839) * [常见问题](files/90100_常见问题.md?t=1595832341004)

@ -6,11 +6,13 @@
```xml ```xml
<properties> <properties>
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version> <!-- springboot 版本-->
<!-- nacos spring cloud版本号 --> <spring-boot.version>2.2.5.RELEASE</spring-boot.version>
<spring-cloud-alibaba-nacos.version>0.9.0.RELEASE</spring-cloud-alibaba-nacos.version> <!-- spring cloud 版本 -->
<!-- nacos客户端版本号 --> <spring-cloud.version>Hoxton.SR3</spring-cloud.version>
<nacos-client.version>1.1.3</nacos-client.version> <!-- spring cloud alibaba 版本 -->
<!-- 具体版本对应关系见:https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E -->
<spring-cloud-alibaba.version>2.2.1.RELEASE</spring-cloud-alibaba.version>
</properties> </properties>
``` ```
@ -19,10 +21,24 @@
```xml ```xml
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId> <artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.RELEASE</version> <version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -40,28 +56,16 @@
<version>最新版本</version> <version>最新版本</version>
</dependency> </dependency>
<!-- 使用nacos注册中心
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
-->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${spring-cloud-alibaba-nacos.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos-client.version}</version>
</dependency> </dependency>
<!-- 注册中心end -->
``` ```
- application.properties配置文件添加 - application.properties配置文件添加
```properties ```properties
server.port=2222 server.port=2222
# 服务名称
spring.application.name=story-service spring.application.name=story-service
# nacos注册中心 # nacos注册中心
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848

@ -32,9 +32,9 @@ import static java.util.Collections.synchronizedMap;
@Slf4j @Slf4j
public class GatewayRouteRepository implements RouteRepository<GatewayTargetRoute>, RouteLocator { public class GatewayRouteRepository implements RouteRepository<GatewayTargetRoute>, RouteLocator {
private PathMatcher pathMatcher = new AntPathMatcher(); private final PathMatcher pathMatcher = new AntPathMatcher();
private final Map<String, GatewayTargetRoute> routes = synchronizedMap(new LinkedHashMap<>()); private static final Map<String, GatewayTargetRoute> routes = synchronizedMap(new LinkedHashMap<>());
@Autowired @Autowired
private RouteLocatorBuilder routeLocatorBuilder; private RouteLocatorBuilder routeLocatorBuilder;
@ -54,7 +54,7 @@ public class GatewayRouteRepository implements RouteRepository<GatewayTargetRout
public void refresh() { public void refresh() {
RouteLocatorBuilder.Builder builder = routeLocatorBuilder.routes(); RouteLocatorBuilder.Builder builder = routeLocatorBuilder.routes();
List<RouteDefinition> routeDefinitionList = this.routes.values() List<RouteDefinition> routeDefinitionList = routes.values()
.stream() .stream()
.map(AbstractTargetRoute::getRouteDefinition) .map(AbstractTargetRoute::getRouteDefinition)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -135,7 +135,7 @@ public class GatewayRouteRepository implements RouteRepository<GatewayTargetRout
@Override @Override
public void deleteAll(String serviceId) { public void deleteAll(String serviceId) {
List<String> idList = this.routes.values().stream() List<String> idList = routes.values().stream()
.filter(zuulTargetRoute -> StringUtils.equalsIgnoreCase(serviceId, zuulTargetRoute.getServiceRouteInfo().getServiceId())) .filter(zuulTargetRoute -> StringUtils.equalsIgnoreCase(serviceId, zuulTargetRoute.getServiceRouteInfo().getServiceId()))
.map(zuulTargetRoute -> zuulTargetRoute.getRouteDefinition().getId()) .map(zuulTargetRoute -> zuulTargetRoute.getRouteDefinition().getId())
.collect(Collectors.toList()); .collect(Collectors.toList());

@ -18,12 +18,12 @@ import java.util.stream.Collectors;
*/ */
public class ZuulRouteRepository implements RouteRepository<ZuulTargetRoute> { public class ZuulRouteRepository implements RouteRepository<ZuulTargetRoute> {
private PathMatcher pathMatcher = new AntPathMatcher(); private final PathMatcher pathMatcher = new AntPathMatcher();
/** /**
* keynameVersion * keynameVersion
*/ */
private Map<String, ZuulTargetRoute> nameVersionTargetRouteMap = new ConcurrentHashMap<>(128); private static final Map<String, ZuulTargetRoute> nameVersionTargetRouteMap = new ConcurrentHashMap<>(128);
@Override @Override
public ZuulTargetRoute get(String id) { public ZuulTargetRoute get(String id) {

@ -1,15 +1,4 @@
server.port=2222 server.port=2222
spring.application.name=story-service spring.application.name=story-service
#server.servlet.context-path=/story-service
# 如果有context-path,必须配下面这句
#spring.cloud.nacos.discovery.metadata.server.servlet.context-path=${server.servlet.context-path}
# nacos注册中心 # nacos注册中心
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
# zipkin服务跟踪
#spring.zipkin.base-url=http://127.0.0.1:9411/
## 设置sleuth收集信息的比率,默认0.1,最大是1,数字越大越耗性能
#spring.sleuth.sampler.probability=1
## dubbo使用zipkin过滤器
#dubbo.provider.filter=tracing
#dubbo.consumer.filter=tracing

Loading…
Cancel
Save