|
|
@ -11,6 +11,7 @@ import com.gitee.sop.gatewaycommon.bean.NacosConfigs; |
|
|
|
import com.gitee.sop.gatewaycommon.bean.ServiceRouteInfo; |
|
|
|
import com.gitee.sop.gatewaycommon.bean.ServiceRouteInfo; |
|
|
|
import com.gitee.sop.gatewaycommon.bean.SopConstants; |
|
|
|
import com.gitee.sop.gatewaycommon.bean.SopConstants; |
|
|
|
import com.gitee.sop.gatewaycommon.bean.TargetRoute; |
|
|
|
import com.gitee.sop.gatewaycommon.bean.TargetRoute; |
|
|
|
|
|
|
|
import com.gitee.sop.gatewaycommon.route.RegistryMetadata; |
|
|
|
import com.gitee.sop.gatewaycommon.route.RegistryListener; |
|
|
|
import com.gitee.sop.gatewaycommon.route.RegistryListener; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
@ -39,7 +40,7 @@ import java.util.Objects; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Deprecated |
|
|
|
@Deprecated |
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
public class ServiceRoutesLoader<T extends TargetRoute> { |
|
|
|
public class ServiceRoutesLoader<T extends TargetRoute> implements RegistryMetadata { |
|
|
|
|
|
|
|
|
|
|
|
private static final String SOP_ROUTES_PATH = "/sop/routes"; |
|
|
|
private static final String SOP_ROUTES_PATH = "/sop/routes"; |
|
|
|
|
|
|
|
|
|
|
@ -140,7 +141,7 @@ public class ServiceRoutesLoader<T extends TargetRoute> { |
|
|
|
* @param instance 服务实例 |
|
|
|
* @param instance 服务实例 |
|
|
|
* @return 返回最终url |
|
|
|
* @return 返回最终url |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static String getRouteRequestUrl(Instance instance) { |
|
|
|
private String getRouteRequestUrl(Instance instance) { |
|
|
|
Map<String, String> metadata = instance.getMetadata(); |
|
|
|
Map<String, String> metadata = instance.getMetadata(); |
|
|
|
String customPath = metadata.get(METADATA_SOP_ROUTES_PATH); |
|
|
|
String customPath = metadata.get(METADATA_SOP_ROUTES_PATH); |
|
|
|
String homeUrl; |
|
|
|
String homeUrl; |
|
|
@ -158,7 +159,7 @@ public class ServiceRoutesLoader<T extends TargetRoute> { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 默认处理
|
|
|
|
// 默认处理
|
|
|
|
homeUrl = getHomeUrl(instance); |
|
|
|
homeUrl = getHomeUrl(instance); |
|
|
|
String contextPath = metadata.getOrDefault(SopConstants.METADATA_SERVER_CONTEXT_PATH, ""); |
|
|
|
String contextPath = this.getContextPath(metadata); |
|
|
|
servletPath = contextPath + SOP_ROUTES_PATH; |
|
|
|
servletPath = contextPath + SOP_ROUTES_PATH; |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(servletPath) && !servletPath.startsWith("/")) { |
|
|
|
if (StringUtils.isNotBlank(servletPath) && !servletPath.startsWith("/")) { |
|
|
|