mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
优化文档显示
This commit is contained in:
@@ -22,6 +22,8 @@ public class SopConstants {
|
||||
|
||||
public static final String REDIRECT_PATH_KEY = "r-path";
|
||||
|
||||
public static final String METADATA_SERVER_CONTEXT_PATH = "server.servlet.context-path";
|
||||
|
||||
/**
|
||||
* 在拦截器中调用获取参数:
|
||||
* String cachedBody = (String)exchange.getAttribute(SopConstants.CACHE_REQUEST_BODY_OBJECT_KEY);
|
||||
|
@@ -9,6 +9,7 @@ import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
|
||||
import com.gitee.sop.gatewaycommon.bean.NacosConfigs;
|
||||
import com.gitee.sop.gatewaycommon.bean.ServiceRouteInfo;
|
||||
import com.gitee.sop.gatewaycommon.bean.SopConstants;
|
||||
import com.gitee.sop.gatewaycommon.bean.TargetRoute;
|
||||
import com.gitee.sop.gatewaycommon.route.RegistryListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -46,8 +47,6 @@ public class ServiceRoutesLoader<T extends TargetRoute> {
|
||||
|
||||
private static final int FIVE_SECONDS = 1000 * 5;
|
||||
|
||||
private static final String METADATA_SERVER_CONTEXT_PATH = "server.servlet.context-path";
|
||||
|
||||
private static final String METADATA_SOP_ROUTES_PATH = "sop.routes.path";
|
||||
|
||||
@Autowired
|
||||
@@ -159,7 +158,7 @@ public class ServiceRoutesLoader<T extends TargetRoute> {
|
||||
} else {
|
||||
// 默认处理
|
||||
homeUrl = getHomeUrl(instance);
|
||||
String contextPath = metadata.getOrDefault(METADATA_SERVER_CONTEXT_PATH, "");
|
||||
String contextPath = metadata.getOrDefault(SopConstants.METADATA_SERVER_CONTEXT_PATH, "");
|
||||
servletPath = contextPath + SOP_ROUTES_PATH;
|
||||
}
|
||||
if (StringUtils.isNotBlank(servletPath) && !servletPath.startsWith("/")) {
|
||||
|
@@ -3,6 +3,7 @@ package com.gitee.sop.gatewaycommon.route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.gitee.sop.gatewaycommon.bean.InstanceDefinition;
|
||||
import com.gitee.sop.gatewaycommon.bean.ServiceRouteInfo;
|
||||
import com.gitee.sop.gatewaycommon.bean.SopConstants;
|
||||
import com.gitee.sop.gatewaycommon.manager.BaseRouteCache;
|
||||
import com.gitee.sop.gatewaycommon.manager.EnvironmentKeys;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -23,8 +24,6 @@ public class ServiceRouteListener extends BaseServiceListener {
|
||||
|
||||
private static final String SOP_ROUTES_PATH = "/sop/routes";
|
||||
|
||||
private static final String METADATA_SERVER_CONTEXT_PATH = "server.servlet.context-path";
|
||||
|
||||
private static final String METADATA_SOP_ROUTES_PATH = "sop.routes.path";
|
||||
|
||||
private static final String HEADER_RESTFUL = "restful";
|
||||
@@ -89,7 +88,7 @@ public class ServiceRouteListener extends BaseServiceListener {
|
||||
} else {
|
||||
// 默认处理
|
||||
homeUrl = getHomeUrl(instance);
|
||||
String contextPath = metadata.getOrDefault(METADATA_SERVER_CONTEXT_PATH, "");
|
||||
String contextPath = metadata.getOrDefault(SopConstants.METADATA_SERVER_CONTEXT_PATH, "");
|
||||
servletPath = contextPath + SOP_ROUTES_PATH;
|
||||
}
|
||||
if (StringUtils.isNotBlank(servletPath) && !servletPath.startsWith("/")) {
|
||||
|
@@ -39,6 +39,8 @@ public class OpenContextImpl<T> implements OpenContext<T> {
|
||||
String bizContent = getBizContent();
|
||||
if (bizContent != null) {
|
||||
bizObject = (T) JSON.parseObject(bizContent, bizClass);
|
||||
} else {
|
||||
bizObject = (T) rootJsonObject.toJavaObject(bizClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,19 +17,6 @@ import java.lang.reflect.Method;
|
||||
*/
|
||||
public class ApiMappingHandlerMapping extends RequestMappingHandlerMapping implements PriorityOrdered {
|
||||
|
||||
private static StringValueResolver stringValueResolver = new ApiMappingStringValueResolver();
|
||||
|
||||
@Override
|
||||
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
|
||||
ApiMapping apiMapping = method.getAnnotation(ApiMapping.class);
|
||||
StringValueResolver valueResolver = null;
|
||||
if (apiMapping != null) {
|
||||
valueResolver = stringValueResolver;
|
||||
}
|
||||
this.setEmbeddedValueResolver(valueResolver);
|
||||
return super.getMappingForMethod(method, handlerType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RequestCondition<?> getCustomMethodCondition(Method method) {
|
||||
method.setAccessible(true);
|
||||
|
Reference in New Issue
Block a user