pull/1664/head
shedfreewu 2 months ago
parent f677379df1
commit b158125b2e

@ -398,30 +398,32 @@ public class GatewayConsulRepo {
} }
} }
for (GroupApi groupApi : groupApiResult.getResult()) { if (groupApiResult != null) {
GroupContext groupContext = groups.get(groupApi.getGroupId()); for (GroupApi groupApi : groupApiResult.getResult()) {
if (groupContext == null) { GroupContext groupContext = groups.get(groupApi.getGroupId());
if (logger.isDebugEnabled()) { if (groupContext == null) {
logger.debug("group api {} not found in group {}", groupApi.getApiId(), groupApi.getGroupId()); if (logger.isDebugEnabled()) {
logger.debug("group api {} not found in group {}", groupApi.getApiId(), groupApi.getGroupId());
}
continue;
} }
continue;
}
GroupContext.ContextRoute contextRoute = new GroupContext.ContextRoute(); GroupContext.ContextRoute contextRoute = new GroupContext.ContextRoute();
contextRoute.setApiId(groupApi.getApiId()); contextRoute.setApiId(groupApi.getApiId());
contextRoute.setHost(groupApi.getHost()); contextRoute.setHost(groupApi.getHost());
contextRoute.setPath(groupApi.getPath()); contextRoute.setPath(groupApi.getPath());
contextRoute.setPathMapping(groupApi.getPathMapping()); contextRoute.setPathMapping(groupApi.getPathMapping());
contextRoute.setMethod(groupApi.getMethod()); contextRoute.setMethod(groupApi.getMethod());
contextRoute.setService(groupApi.getServiceName()); contextRoute.setService(groupApi.getServiceName());
contextRoute.setNamespaceId(groupApi.getNamespaceId()); contextRoute.setNamespaceId(groupApi.getNamespaceId());
contextRoute.setNamespace(groupApi.getNamespaceName()); contextRoute.setNamespace(groupApi.getNamespaceName());
if (groupApi.getTimeout() != null) { if (groupApi.getTimeout() != null) {
Map<String, String> metadata = new HashMap<>(); Map<String, String> metadata = new HashMap<>();
metadata.put("response-timeout", String.valueOf(groupApi.getTimeout())); metadata.put("response-timeout", String.valueOf(groupApi.getTimeout()));
contextRoute.setMetadata(metadata); contextRoute.setMetadata(metadata);
}
groupContext.getRoutes().add(contextRoute);
} }
groupContext.getRoutes().add(contextRoute);
} }
if (pathWildcardResult != null && pathWildcardResult.getResult() != null) { if (pathWildcardResult != null && pathWildcardResult.getResult() != null) {
@ -446,7 +448,7 @@ public class GatewayConsulRepo {
contextGatewayProperties.setGroups(groups); contextGatewayProperties.setGroups(groups);
contextGatewayProperties.setRoutes(routes); contextGatewayProperties.setRoutes(routes);
contextGatewayProperties.setPathRewrites(Optional.ofNullable(pathRewriteResult.getResult()) contextGatewayProperties.setPathRewrites(Optional.ofNullable(pathRewriteResult).map(PathRewriteResult::getResult)
.orElse(new ArrayList<>())); .orElse(new ArrayList<>()));
logger.debug("Gateway config loaded. :{}", JacksonUtils.serialize2Json(contextGatewayProperties)); logger.debug("Gateway config loaded. :{}", JacksonUtils.serialize2Json(contextGatewayProperties));

Loading…
Cancel
Save