Browse Source

Fixes the addition of http with EL syntax. Fixes #1796

pull/6/head
Ryan Baxter 8 years ago
parent
commit
02226f938e
  1. 2
      spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientsRegistrar.java
  2. 9
      spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/FeignHttpClientUrlTests.java

2
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientsRegistrar.java

@ -248,7 +248,7 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar, @@ -248,7 +248,7 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar,
private String getUrl(Map<String, Object> attributes) {
String url = resolve((String) attributes.get("url"));
if (StringUtils.hasText(url) && !(url.startsWith("#{") && url.endsWith("}"))) {
if (StringUtils.hasText(url) && !(url.startsWith("#{") && url.contains("}"))) {
if (!url.contains("://")) {
url = "http://" + url;
}

9
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/FeignHttpClientUrlTests.java

@ -88,13 +88,13 @@ public class FeignHttpClientUrlTests { @@ -88,13 +88,13 @@ public class FeignHttpClientUrlTests {
Hello getHello();
}
@FeignClient(name = "beanappurl", url = "#{SERVER_URL}")
@FeignClient(name = "beanappurl", url = "#{SERVER_URL}path")
protected interface BeanUrlClient {
@RequestMapping(method = RequestMethod.GET, value = "/hello")
Hello getHello();
}
@FeignClient(name = "beanappurlnoprotocol", url = "#{SERVER_URL_NO_PROTOCOL}")
@FeignClient(name = "beanappurlnoprotocol", url = "#{SERVER_URL_NO_PROTOCOL}path")
protected interface BeanUrlClientNoProtocol {
@RequestMapping(method = RequestMethod.GET, value = "/hello")
Hello getHello();
@ -113,6 +113,11 @@ public class FeignHttpClientUrlTests { @@ -113,6 +113,11 @@ public class FeignHttpClientUrlTests {
return new Hello("hello world 1");
}
@RequestMapping(method = RequestMethod.GET, value = "/path/hello")
public Hello getHelloWithPath() {
return getHello();
}
@Bean(name="SERVER_URL")
public String serverUrl() {
return "http://localhost:" + port + "/";

Loading…
Cancel
Save