|
@ -8,7 +8,6 @@ import com.yihu.hos.core.http.HttpClientKit;
|
|
|
import org.apache.camel.Exchange;
|
|
|
import org.apache.camel.Processor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cloud.client.ServiceInstance;
|
|
|
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@ -17,7 +16,6 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@ -27,9 +25,7 @@ import java.util.stream.Stream;
|
|
|
public class GatewayProcessor implements Processor {
|
|
|
static Map<String, AppApi> apiMap = new HashMap<>();
|
|
|
static final String agUrl = "http://192.168.1.221:10000";
|
|
|
@Autowired
|
|
|
ParamVerifyBean paramSign;
|
|
|
|
|
|
static final String brokerUrl = "http://127.0.0.1:8099";
|
|
|
@Autowired
|
|
|
private DiscoveryClient discoveryClient;
|
|
|
|
|
@ -119,6 +115,7 @@ public class GatewayProcessor implements Processor {
|
|
|
try {
|
|
|
String sign = params.get("sign").toString(); // 簽名
|
|
|
|
|
|
ParamVerifyBean paramSign = new ParamVerifyBean();
|
|
|
paramSign.addParam(params);
|
|
|
// paramSign.genParam();
|
|
|
//TODO 获取app secret传入验证
|
|
@ -275,13 +272,14 @@ public class GatewayProcessor implements Processor {
|
|
|
* @return
|
|
|
*/
|
|
|
public String serviceUrl(String serviceName) {
|
|
|
List<ServiceInstance> instances = discoveryClient.getInstances(serviceName);
|
|
|
if (instances != null && !instances.isEmpty()) {
|
|
|
ServiceInstance serviceInstance = instances.get(0);
|
|
|
return serviceInstance.getUri().toString();
|
|
|
} else {
|
|
|
return null;
|
|
|
HTTPResponse response = HttpClientKit.get(brokerUrl + "/esb/webservice/host?serviceName=" + serviceName);
|
|
|
if (response.getStatusCode() != 200) {
|
|
|
System.out.println("获取服务地址请求失败!");
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
return response.getBody();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|