INNER CODE UNIT · Java

createConsulClientBaseUrl

spring-cloud/spring-cloud-consul · spring-cloud-consul-core/src/main/java/org/springframework/cloud/consul/ConsulAutoConfiguration.java:101

	public static String createConsulClientBaseUrl(ConsulProperties consulProperties) {
		UriBuilder uriBuilder = new DefaultUriBuilderFactory().builder();

		if (StringUtils.hasLength(consulProperties.getScheme())) {
			uriBuilder.scheme(consulProperties.getScheme());
		}
		else {
			uriBuilder.scheme("http");
		}

		uriBuilder.host(consulProperties.getHost()).port(consulProperties.getPort());

		final String agentPath = consulProperties.getPath();
		if (StringUtils.hasLength(agentPath)) {
			String normalizedAgentPath = StringUtils.trimTrailingCharacter(agentPath, '/');
			normalizedAgentPath = StringUtils.trimLeadingCharacter(normalizedAgentPath, '/');

			uriBuilder.path(normalizedAgentPath);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…