Java Code Examples for org.springframework.cloud.client.ServiceInstance#isSecure()

The following examples show how to use org.springframework.cloud.client.ServiceInstance#isSecure() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InstanceDiscoveryListener.java    From Moss with Apache License 2.0 5 votes vote down vote up
protected String toString(ServiceInstance instance) {
    String httpScheme = instance.isSecure() ? "https" : "http";
    return String.format("serviceId=%s, instanceId=%s, url= %s://%s:%d",
        instance.getServiceId(), instance.getInstanceId(),
        instance.getScheme() != null ? instance.getScheme() : httpScheme,
        instance.getHost(),
        instance.getPort()
    );
}
 
Example 2
Source File: MossInstanceDiscoveryListener.java    From Moss with Apache License 2.0 5 votes vote down vote up
protected String toString(ServiceInstance instance) {
    String httpScheme = instance.isSecure() ? "https" : "http";
    return String.format("serviceId=%s, instanceId=%s, url= %s://%s:%d",
            instance.getServiceId(),
            instance.getScheme() != null ? instance.getScheme() : httpScheme,
            instance.getHost(),
            instance.getPort()
    );
}
 
Example 3
Source File: NamingService.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public static NamingService convert(ServiceInstance instance) {
    NamingService namingService = new NamingService();
    namingService.serviceId = instance.getServiceId();
    namingService.instanceId = instance.getInstanceId();
    namingService.host = instance.getHost();
    namingService.port = instance.getPort();
    namingService.uri = instance.getUri().toString();
    namingService.secure = instance.isSecure();

    return namingService;
}
 
Example 4
Source File: NacosServiceDiscoveryTest.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
private String getUri(ServiceInstance instance) {

		if (instance.isSecure()) {
			return "https://" + host + ":" + port;
		}

		return "http://" + host + ":" + port;
	}
 
Example 5
Source File: AbstractMicroserviceClient.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a url for rest template
 *
 * @param path resource path on the service
 * @return a url String for use in RestTemplate
 */
protected String getUrl(String path) {
    String url;
    ServiceInstance instance = loadBalancerClient.choose(serviceName);
    String prefix = instance.isSecure() ? "https://" : "http://";

    url = prefix + instance.getHost() + ":" + instance.getPort() + "/api/" + path;


    return url;
}
 
Example 6
Source File: LoadBalancerUriTools.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
private static String computeScheme(URI original, ServiceInstance serviceInstance) {
	String originalOrDefault = Optional.ofNullable(original.getScheme())
			.orElse(DEFAULT_SCHEME);
	if (serviceInstance.isSecure()
			&& INSECURE_SCHEME_MAPPINGS.containsKey(originalOrDefault)) {
		return INSECURE_SCHEME_MAPPINGS.get(originalOrDefault);
	}
	return originalOrDefault;
}
 
Example 7
Source File: WebSocketProxyServerHandler.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
private String getTargetUrl(String serviceUrl, ServiceInstance serviceInstance, String path) {
    String servicePath = serviceUrl.charAt(serviceUrl.length() - 1) == '/' ? serviceUrl : serviceUrl + SEPARATOR;
    return (serviceInstance.isSecure() ? "wss" : "ws") + "://" + serviceInstance.getHost() + ":"
        + serviceInstance.getPort() + servicePath + path;
}
 
Example 8
Source File: InstanceDiscoveryListener.java    From spring-boot-admin with Apache License 2.0 4 votes vote down vote up
protected String toString(ServiceInstance instance) {
	String httpScheme = instance.isSecure() ? "https" : "http";
	return String.format("serviceId=%s, instanceId=%s, url= %s://%s:%d", instance.getServiceId(),
			instance.getInstanceId(), (instance.getScheme() != null) ? instance.getScheme() : httpScheme,
			instance.getHost(), instance.getPort());
}