fix:serviceId大小写问题

pull/10/MERGE
tanghc 4 years ago
parent db9a2f4e23
commit de22c333d0
  1. 14
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/route/ServiceRouteListener.java

@ -45,13 +45,25 @@ public class ServiceRouteListener extends BaseServiceListener {
ResponseEntity<String> responseEntity = getRestTemplate().getForEntity(url, String.class); ResponseEntity<String> responseEntity = getRestTemplate().getForEntity(url, String.class);
if (responseEntity.getStatusCode() == HttpStatus.OK) { if (responseEntity.getStatusCode() == HttpStatus.OK) {
String body = responseEntity.getBody(); String body = responseEntity.getBody();
ServiceRouteInfo serviceRouteInfo = JSON.parseObject(body, ServiceRouteInfo.class); ServiceRouteInfo serviceRouteInfo;
try {
serviceRouteInfo = this.parseServiceRouteInfo(body);
} catch (Exception e) {
log.error("解析路由配置错误,body:{}", body, e);
return;
}
gatewayRouteCache.load(serviceRouteInfo, callback -> routesProcessor.saveRoutes(serviceRouteInfo, instance)); gatewayRouteCache.load(serviceRouteInfo, callback -> routesProcessor.saveRoutes(serviceRouteInfo, instance));
} else { } else {
log.error("拉取路由配置异常,url: {}, status: {}, body: {}", url, responseEntity.getStatusCodeValue(), responseEntity.getBody()); log.error("拉取路由配置异常,url: {}, status: {}, body: {}", url, responseEntity.getStatusCodeValue(), responseEntity.getBody());
} }
} }
private ServiceRouteInfo parseServiceRouteInfo(String body) {
ServiceRouteInfo serviceRouteInfo = JSON.parseObject(body, ServiceRouteInfo.class);
serviceRouteInfo.setServiceId(serviceRouteInfo.getServiceId().toLowerCase());
return serviceRouteInfo;
}
protected HttpEntity<String> getHttpEntity() { protected HttpEntity<String> getHttpEntity() {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
return new HttpEntity<>(headers); return new HttpEntity<>(headers);

Loading…
Cancel
Save