Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
edb14e2a
Commit
edb14e2a
authored
Dec 05, 2016
by
Ryan Baxter
Committed by
GitHub
Dec 05, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1528 from ryanjbaxter/feign-url-protocol-1522
Don’t add URL protocol when url is set using EL
parents
ac3401bc
6a826441
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
FeignClientsRegistrar.java
...gframework/cloud/netflix/feign/FeignClientsRegistrar.java
+1
-1
FeignHttpClientUrlTests.java
...ramework/cloud/netflix/feign/FeignHttpClientUrlTests.java
+45
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientsRegistrar.java
View file @
edb14e2a
...
...
@@ -243,7 +243,7 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar,
private
String
getUrl
(
Map
<
String
,
Object
>
attributes
)
{
String
url
=
resolve
((
String
)
attributes
.
get
(
"url"
));
if
(
StringUtils
.
hasText
(
url
))
{
if
(
StringUtils
.
hasText
(
url
)
&&
!(
url
.
startsWith
(
"#{"
)
&&
url
.
endsWith
(
"}"
))
)
{
if
(!
url
.
contains
(
"://"
))
{
url
=
"http://"
+
url
;
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/FeignHttpClientUrlTests.java
View file @
edb14e2a
...
...
@@ -30,6 +30,7 @@ import org.junit.BeforeClass;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest.WebEnvironment
;
...
...
@@ -75,6 +76,11 @@ public class FeignHttpClientUrlTests {
@Autowired
private
UrlClient
urlClient
;
@Autowired
private
BeanUrlClient
beanClient
;
@Autowired
BeanUrlClientNoProtocol
beanClientNoProtocol
;
// this tests that
@FeignClient
(
name
=
"localappurl"
,
url
=
"http://localhost:${server.port}/"
)
protected
interface
UrlClient
{
...
...
@@ -82,17 +88,41 @@ public class FeignHttpClientUrlTests {
Hello
getHello
();
}
@FeignClient
(
name
=
"beanappurl"
,
url
=
"#{SERVER_URL}"
)
protected
interface
BeanUrlClient
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
Hello
getHello
();
}
@FeignClient
(
name
=
"beanappurlnoprotocol"
,
url
=
"#{SERVER_URL_NO_PROTOCOL}"
)
protected
interface
BeanUrlClientNoProtocol
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
Hello
getHello
();
}
@Configuration
@EnableAutoConfiguration
@RestController
@EnableFeignClients
(
clients
=
{
UrlClient
.
class
})
@EnableFeignClients
(
clients
=
{
UrlClient
.
class
,
BeanUrlClient
.
class
,
BeanUrlClientNoProtocol
.
class
})
protected
static
class
TestConfig
{
@Value
(
"${server.port}"
)
private
int
port
;
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
public
Hello
getHello
()
{
return
new
Hello
(
"hello world 1"
);
}
@Bean
(
name
=
"SERVER_URL"
)
public
String
serverUrl
()
{
return
"http://localhost:"
+
port
+
"/"
;
}
@Bean
(
name
=
"SERVER_URL_NO_PROTOCOL"
)
public
String
serverUrlNoProtocol
()
{
return
"localhost:"
+
port
+
"/"
;
}
@Bean
public
Targeter
feignTargeter
()
{
return
new
Targeter
()
{
...
...
@@ -122,6 +152,20 @@ public class FeignHttpClientUrlTests {
assertEquals
(
"first hello didn't match"
,
new
Hello
(
"hello world 1"
),
hello
);
}
@Test
public
void
testBeanUrl
()
{
Hello
hello
=
this
.
beanClient
.
getHello
();
assertNotNull
(
"hello was null"
,
hello
);
assertEquals
(
"first hello didn't match"
,
new
Hello
(
"hello world 1"
),
hello
);
}
@Test
public
void
testBeanUrlNoProtocol
()
{
Hello
hello
=
this
.
beanClientNoProtocol
.
getHello
();
assertNotNull
(
"hello was null"
,
hello
);
assertEquals
(
"first hello didn't match"
,
new
Hello
(
"hello world 1"
),
hello
);
}
@Data
@AllArgsConstructor
@NoArgsConstructor
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment