This commit is contained in:
tanghc
2019-07-25 13:51:03 +08:00
parent 55ca508905
commit eb4612f22f
8 changed files with 51 additions and 53 deletions

View File

@@ -2,7 +2,7 @@ package com.gitee.sop.gateway.controller;
import com.gitee.sop.gatewaycommon.bean.SopConstants;
import com.gitee.sop.gatewaycommon.param.ParamNames;
import com.gitee.sop.gatewaycommon.util.MappingUtil;
import com.gitee.sop.gatewaycommon.util.RouteUtil;
import org.springframework.beans.factory.annotation.Value;
import javax.servlet.ServletException;
@@ -17,9 +17,12 @@ public class RestServlet extends HttpServlet {
private static final String REST_PATH = "/rest";
@Value("${zuul.servlet-path}")
@Value("${zuul.servlet-path:/zuul}")
private String path;
@Value("${zuul.rest-default-version:1.0}")
private String defaultVersion;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
@@ -31,10 +34,10 @@ public class RestServlet extends HttpServlet {
int index = url.indexOf(REST_PATH);
// 取/rest的后面部分
String path = url.substring(index + REST_PATH.length());
String method = MappingUtil.buildApiName(path);
String method = RouteUtil.buildApiName(path);
String version = request.getParameter(ParamNames.VERSION_NAME);
if (version == null) {
version = "1.0";
version = defaultVersion;
}
request.setAttribute(SopConstants.REDIRECT_METHOD_KEY, method);
request.setAttribute(SopConstants.REDIRECT_VERSION_KEY, version);

View File

@@ -21,6 +21,8 @@ zuul.FormBodyWrapperFilter.pre.disable=true
zuul.Servlet30WrapperFilter.pre.disable=true
# 不用改,如果要改,请全局替换修改
zuul.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC
# 不用改
zuul.rest-default-version=1.0
# https://blog.csdn.net/qq_36872046/article/details/81058045
# 路由转发超时时间毫秒默认值1000详见RibbonClientConfiguration.DEFAULT_READ_TIMEOUT。