pull/1/head
tanghc 5 years ago
parent 41386f6996
commit 3871132b55
  1. 4
      changelog.md
  2. 64
      doc/docs/_sidebar.md
  3. 2
      doc/docs/files/10070_easyopen支持.md
  4. 8
      doc/docs/files/10100_提供restful接口.md
  5. 2
      sop-auth/pom.xml
  6. 2
      sop-common/pom.xml
  7. 4
      sop-common/sop-gateway-common/pom.xml
  8. 4
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/EnvironmentKeys.java
  9. 8
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/route/ServiceRouteListener.java
  10. 4
      sop-common/sop-service-common/pom.xml
  11. 2
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceContext.java
  12. 2
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ApiMetaBuilder.java
  13. 8
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceRouteController.java
  14. 2
      sop-example/sop-book/sop-book-web/pom.xml
  15. 2
      sop-example/sop-easyopen/pom.xml
  16. 2
      sop-example/sop-springmvc/pom.xml
  17. 2
      sop-example/sop-story/sop-story-web/pom.xml
  18. 2
      sop-gateway/pom.xml
  19. 2
      sop-website/pom.xml

@ -1,5 +1,9 @@
# changelog # changelog
## 2.3.0
- 支持请求restful接口(设置`sop.restful.enable=true`)
## 2.2.0(需要执行`sop-2.2.0.sql`升级文件) ## 2.2.0(需要执行`sop-2.2.0.sql`升级文件)
- 支持eureka注册中心,见`eureka`分支 - 支持eureka注册中心,见`eureka`分支

@ -1,34 +1,34 @@
* [首页](/?t=1570520682411) * [首页](/?t=1570521912278)
* 开发文档 * 开发文档
* [快速体验](files/10010_快速体验.md?t=1570520682413) * [快速体验](files/10010_快速体验.md?t=1570521912281)
* [项目接入到SOP](files/10011_项目接入到SOP.md?t=1570520682439) * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1570521912300)
* [新增接口](files/10020_新增接口.md?t=1570520682440) * [新增接口](files/10020_新增接口.md?t=1570521912300)
* [开发流程](files/10021_开发流程.md?t=1570520682440) * [开发流程](files/10021_开发流程.md?t=1570521912300)
* [业务参数校验](files/10030_业务参数校验.md?t=1570520682440) * [业务参数校验](files/10030_业务参数校验.md?t=1570521912301)
* [错误处理](files/10040_错误处理.md?t=1570520682440) * [错误处理](files/10040_错误处理.md?t=1570521912301)
* [编写文档](files/10041_编写文档.md?t=1570520682440) * [编写文档](files/10041_编写文档.md?t=1570521912301)
* [接口交互详解](files/10050_接口交互详解.md?t=1570520682440) * [接口交互详解](files/10050_接口交互详解.md?t=1570521912301)
* [easyopen支持](files/10070_easyopen支持.md?t=1570520682440) * [easyopen支持](files/10070_easyopen支持.md?t=1570521912301)
* [使用签名校验工具](files/10080_使用签名校验工具.md?t=1570520682440) * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1570521912301)
* [ISV管理](files/10085_ISV管理.md?t=1570520682441) * [ISV管理](files/10085_ISV管理.md?t=1570521912301)
* [自定义返回结果](files/10087_自定义返回结果.md?t=1570520682441) * [自定义返回结果](files/10087_自定义返回结果.md?t=1570521912301)
* [自定义过滤器](files/10088_自定义过滤器.md?t=1570520682441) * [自定义过滤器](files/10088_自定义过滤器.md?t=1570521912302)
* [路由授权](files/10090_路由授权.md?t=1570520682441) * [路由授权](files/10090_路由授权.md?t=1570521912302)
* [接口限流](files/10092_接口限流.md?t=1570520682441) * [接口限流](files/10092_接口限流.md?t=1570521912302)
* [监控日志](files/10093_监控日志.md?t=1570520682441) * [监控日志](files/10093_监控日志.md?t=1570521912302)
* [SDK开发](files/10095_SDK开发.md?t=1570520682441) * [SDK开发](files/10095_SDK开发.md?t=1570521912302)
* [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1570520682441) * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1570521912302)
* [应用授权](files/10097_应用授权.md?t=1570520682442) * [应用授权](files/10097_应用授权.md?t=1570521912302)
* [传统web开发](files/10100_传统web开发.md?t=1570520682442) * [提供restful接口](files/10100_提供restful接口.md?t=1570521912302)
* [文件上传](files/10104_文件上传.md?t=1570520682442) * [文件上传](files/10104_文件上传.md?t=1570521912302)
* [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1570520682442) * [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1570521912303)
* [预发布灰度发布](files/10110_预发布灰度发布.md?t=1570520682442) * [预发布灰度发布](files/10110_预发布灰度发布.md?t=1570521912303)
* [动态修改请求参数](files/10111_动态修改请求参数.md?t=1570520682442) * [动态修改请求参数](files/10111_动态修改请求参数.md?t=1570521912303)
* [使用eureka](files/10112_使用eureka.md?t=1570520682442) * [使用eureka](files/10112_使用eureka.md?t=1570521912303)
* [扩展其它注册中心](files/10113_扩展其它注册中心.md?t=1570520682442) * [扩展其它注册中心](files/10113_扩展其它注册中心.md?t=1570521912303)
* 原理分析 * 原理分析
* [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1570520682442) * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1570521912303)
* [原理分析之如何存储路由](files/90011_原理分析之如何存储路由.md?t=1570520682442) * [原理分析之如何存储路由](files/90011_原理分析之如何存储路由.md?t=1570521912303)
* [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1570520682442) * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1570521912303)
* [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1570520682442) * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1570521912303)
* [常见问题](files/90100_常见问题.md?t=1570520682443) * [常见问题](files/90100_常见问题.md?t=1570521912303)

@ -13,7 +13,7 @@ SOP对easyopen项目提供了很好的支持,如果您的服务端使用了eas
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId> <artifactId>sop-service-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- 使用nacos注册中心 <!-- 使用nacos注册中心

@ -1,14 +1,14 @@
# 传统web开发 # 传统web开发
SOP既可以作为网关服务开发,又可以作为传统的webapp服务开发,传统web开发意思是像普通的web开发那样提供restful接口,没有签名校验功能 默认情况下SOP只提供开放接口,也可以同时提供restful接口,即程序提供一部分的开放接口,同时提供一部分restful接口
本篇介绍如何使用SOP进行传统web服务开发,即对接前端应用(H5、小程序、App)。 默认情况下提供restful功能是关闭的,开启方式如下:
- 打开sop-gateway配置文件,新增一行配置: - 打开sop-gateway配置文件,新增一行配置:
```properties ```properties
# 开启传统的webapp服务开发 # 提供restful接口
sop.web-model.enable=true sop.restful.enable=true
``` ```
- 前端app请求网关 - 前端app请求网关

@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId> <artifactId>sop-service-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- sop相关配置 end--> <!-- sop相关配置 end-->

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId> <artifactId>sop-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<properties> <properties>

@ -5,11 +5,11 @@
<parent> <parent>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId> <artifactId>sop-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>sop-gateway-common</artifactId> <artifactId>sop-gateway-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>sop-gateway-common</name> <name>sop-gateway-common</name>

@ -19,9 +19,9 @@ public enum EnvironmentKeys {
SIGN_URLENCODE("sign.urlencode"), SIGN_URLENCODE("sign.urlencode"),
/** /**
* sop.web-model.enable=true开启传统web开发模式 * sop.restful.enable=true开启传统web开发模式
*/ */
SOP_WEB_MODEL_ENABLE("sop.web-model.enable"); SOP_RESTFUL_ENABLE("sop.restful.enable");
private String key; private String key;
private String defaultValue; private String defaultValue;

@ -27,7 +27,7 @@ public class ServiceRouteListener extends BaseServiceListener {
private static final String METADATA_SOP_ROUTES_PATH = "sop.routes.path"; private static final String METADATA_SOP_ROUTES_PATH = "sop.routes.path";
private static final String HEADER_WEB_MODEL = "web-model"; private static final String HEADER_RESTFUL = "restful";
@Autowired @Autowired
private BaseRouteCache<?> baseRouteCache; private BaseRouteCache<?> baseRouteCache;
@ -59,9 +59,9 @@ public class ServiceRouteListener extends BaseServiceListener {
protected HttpEntity<String> getHttpEntity() { protected HttpEntity<String> getHttpEntity() {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
String webModel = EnvironmentKeys.SOP_WEB_MODEL_ENABLE.getValue(); String restful = EnvironmentKeys.SOP_RESTFUL_ENABLE.getValue();
boolean isWebModel = "true".equals(webModel); boolean enableRestful = "true".equals(restful);
headers.add(HEADER_WEB_MODEL, String.valueOf(isWebModel)); headers.add(HEADER_RESTFUL, String.valueOf(enableRestful));
return new HttpEntity<>(headers); return new HttpEntity<>(headers);
} }

@ -6,11 +6,11 @@
<parent> <parent>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId> <artifactId>sop-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>sop-service-common</artifactId> <artifactId>sop-service-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>sop-service-common</name> <name>sop-service-common</name>

@ -14,7 +14,7 @@ public class ServiceContext extends ConcurrentHashMap<String, Object> {
public static final String RESPONSE_KEY = "response"; public static final String RESPONSE_KEY = "response";
public static final String OPEN_CONTEXT_KEY = "openContext"; public static final String OPEN_CONTEXT_KEY = "openContext";
public static final String WEB_MODEL_KEY = "sop-web-model"; public static final String RESTFUL_KEY = "sop-restful";
protected static Class<? extends ServiceContext> contextClass = ServiceContext.class; protected static Class<? extends ServiceContext> contextClass = ServiceContext.class;

@ -88,7 +88,7 @@ public class ApiMetaBuilder {
apiMeta.setPermission(BooleanUtils.toInteger(apiMappingInfo.isPermission())); apiMeta.setPermission(BooleanUtils.toInteger(apiMappingInfo.isPermission()));
return apiMeta; return apiMeta;
} else { } else {
if (!ServiceContext.getCurrentContext().getBoolean(ServiceContext.WEB_MODEL_KEY, false)) { if (!ServiceContext.getCurrentContext().getBoolean(ServiceContext.RESTFUL_KEY, false)) {
return null; return null;
} }
String path = patterns.iterator().next(); String path = patterns.iterator().next();

@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletResponse;
public class ServiceRouteController { public class ServiceRouteController {
private static final String SECRET = "a3d9sf!1@odl90zd>fkASwq"; private static final String SECRET = "a3d9sf!1@odl90zd>fkASwq";
private static final String HEADER_WEB_MODEL = "web-model"; private static final String HEADER_RESTFUL = "restful";
@Autowired @Autowired
private RequestMappingHandlerMapping requestMappingHandlerMapping; private RequestMappingHandlerMapping requestMappingHandlerMapping;
@ -52,9 +52,9 @@ public class ServiceRouteController {
throw new IllegalArgumentException("未指定spring.application.name参数"); throw new IllegalArgumentException("未指定spring.application.name参数");
} }
ApiMetaBuilder apiMetaBuilder = getApiMetaBuilder(); ApiMetaBuilder apiMetaBuilder = getApiMetaBuilder();
String webModel = request.getHeader(HEADER_WEB_MODEL); String restful = request.getHeader(HEADER_RESTFUL);
boolean isWebModel = "true".equals(webModel); boolean enableRestful = "true".equals(restful);
ServiceContext.getCurrentContext().set(ServiceContext.WEB_MODEL_KEY, isWebModel); ServiceContext.getCurrentContext().set(ServiceContext.RESTFUL_KEY, enableRestful);
ServiceApiInfo serviceApiInfo = apiMetaBuilder.getServiceApiInfo(serviceId, requestMappingHandlerMapping); ServiceApiInfo serviceApiInfo = apiMetaBuilder.getServiceApiInfo(serviceId, requestMappingHandlerMapping);
ServiceRouteInfoBuilder serviceRouteInfoBuilder = new ServiceRouteInfoBuilder(environment); ServiceRouteInfoBuilder serviceRouteInfoBuilder = new ServiceRouteInfoBuilder(environment);
return serviceRouteInfoBuilder.build(serviceApiInfo); return serviceRouteInfoBuilder.build(serviceApiInfo);

@ -28,7 +28,7 @@
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId> <artifactId>sop-service-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>

@ -29,7 +29,7 @@
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId> <artifactId>sop-service-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- 使用nacos注册中心 <!-- 使用nacos注册中心

@ -20,7 +20,7 @@
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId> <artifactId>sop-service-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- nacos --> <!-- nacos -->
<dependency> <dependency>

@ -28,7 +28,7 @@
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId> <artifactId>sop-service-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>

@ -29,7 +29,7 @@
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId> <artifactId>sop-gateway-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- ↓↓↓ 使用spring cloud zuul ↓↓↓ --> <!-- ↓↓↓ 使用spring cloud zuul ↓↓↓ -->

@ -35,7 +35,7 @@
<dependency> <dependency>
<groupId>com.gitee.sop</groupId> <groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId> <artifactId>sop-gateway-common</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

Loading…
Cancel
Save