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
d19a6f26
Unverified
Commit
d19a6f26
authored
May 23, 2016
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use RouteLocator interface.
fixes gh-1030
parent
c3f12106
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
2 deletions
+28
-2
ZuulConfiguration.java
...springframework/cloud/netflix/zuul/ZuulConfiguration.java
+1
-1
ZuulProxyConfiguration.java
...gframework/cloud/netflix/zuul/ZuulProxyConfiguration.java
+1
-1
SampleZuulProxyApplicationTests.java
...k/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
+26
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java
View file @
d19a6f26
...
@@ -76,7 +76,7 @@ public class ZuulConfiguration {
...
@@ -76,7 +76,7 @@ public class ZuulConfiguration {
}
}
@Bean
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean
(
RouteLocator
.
class
)
public
RouteLocator
routeLocator
()
{
public
RouteLocator
routeLocator
()
{
return
new
SimpleRouteLocator
(
this
.
server
.
getServletPrefix
(),
return
new
SimpleRouteLocator
(
this
.
server
.
getServletPrefix
(),
this
.
zuulProperties
);
this
.
zuulProperties
);
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulProxyConfiguration.java
View file @
d19a6f26
...
@@ -135,7 +135,7 @@ public class ZuulProxyConfiguration extends ZuulConfiguration {
...
@@ -135,7 +135,7 @@ public class ZuulProxyConfiguration extends ZuulConfiguration {
protected
static
class
RoutesEndpointConfiguration
{
protected
static
class
RoutesEndpointConfiguration
{
@Bean
@Bean
public
RoutesEndpoint
zuulEndpoint
(
DiscoveryClient
RouteLocator
routeLocator
)
{
public
RoutesEndpoint
zuulEndpoint
(
RouteLocator
routeLocator
)
{
return
new
RoutesEndpoint
(
routeLocator
);
return
new
RoutesEndpoint
(
routeLocator
);
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
View file @
d19a6f26
...
@@ -24,15 +24,20 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -24,15 +24,20 @@ import javax.servlet.http.HttpServletRequest;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.netflix.ribbon.RibbonClient
;
import
org.springframework.cloud.netflix.ribbon.RibbonClient
;
import
org.springframework.cloud.netflix.ribbon.RibbonClients
;
import
org.springframework.cloud.netflix.ribbon.RibbonClients
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.StaticServerList
;
import
org.springframework.cloud.netflix.ribbon.StaticServerList
;
import
org.springframework.cloud.netflix.zuul.filters.RouteLocator
;
import
org.springframework.cloud.netflix.zuul.filters.ZuulProperties
;
import
org.springframework.cloud.netflix.zuul.filters.discovery.DiscoveryClientRouteLocator
;
import
org.springframework.cloud.netflix.zuul.filters.route.RestClientRibbonCommand
;
import
org.springframework.cloud.netflix.zuul.filters.route.RestClientRibbonCommand
;
import
org.springframework.cloud.netflix.zuul.filters.route.RestClientRibbonCommandFactory
;
import
org.springframework.cloud.netflix.zuul.filters.route.RestClientRibbonCommandFactory
;
import
org.springframework.cloud.netflix.zuul.filters.route.RibbonCommandContext
;
import
org.springframework.cloud.netflix.zuul.filters.route.RibbonCommandContext
;
...
@@ -82,6 +87,9 @@ import lombok.SneakyThrows;
...
@@ -82,6 +87,9 @@ import lombok.SneakyThrows;
@DirtiesContext
@DirtiesContext
public
class
SampleZuulProxyApplicationTests
extends
ZuulProxyTestBase
{
public
class
SampleZuulProxyApplicationTests
extends
ZuulProxyTestBase
{
@Autowired
RouteLocator
routeLocator
;
@Test
@Test
public
void
simpleHostRouteWithTrailingSlash
()
{
public
void
simpleHostRouteWithTrailingSlash
()
{
this
.
routes
.
addRoute
(
"/self/**"
,
"http://localhost:"
+
this
.
port
+
"/"
);
this
.
routes
.
addRoute
(
"/self/**"
,
"http://localhost:"
+
this
.
port
+
"/"
);
...
@@ -191,6 +199,12 @@ public class SampleZuulProxyApplicationTests extends ZuulProxyTestBase {
...
@@ -191,6 +199,12 @@ public class SampleZuulProxyApplicationTests extends ZuulProxyTestBase {
this
.
ribbonCommandFactory
instanceof
SampleZuulProxyApplication
.
MyRibbonCommandFactory
);
this
.
ribbonCommandFactory
instanceof
SampleZuulProxyApplication
.
MyRibbonCommandFactory
);
}
}
@Test
public
void
routeLocatorOverridden
()
{
assertTrue
(
"routeLocator not a MyRouteLocator"
,
this
.
routeLocator
instanceof
SampleZuulProxyApplication
.
MyRouteLocator
);
}
}
}
// Don't use @SpringBootApplication because we don't want to component scan
// Don't use @SpringBootApplication because we don't want to component scan
...
@@ -238,6 +252,11 @@ class SampleZuulProxyApplication extends ZuulProxyTestBase.AbstractZuulProxyAppl
...
@@ -238,6 +252,11 @@ class SampleZuulProxyApplication extends ZuulProxyTestBase.AbstractZuulProxyAppl
return
new
MyRibbonCommandFactory
(
clientFactory
);
return
new
MyRibbonCommandFactory
(
clientFactory
);
}
}
@Bean
public
RouteLocator
routeLocator
(
DiscoveryClient
discoveryClient
,
ZuulProperties
zuulProperties
)
{
return
new
MyRouteLocator
(
"/"
,
discoveryClient
,
zuulProperties
);
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SampleZuulProxyApplication
.
class
,
args
);
SpringApplication
.
run
(
SampleZuulProxyApplication
.
class
,
args
);
}
}
...
@@ -299,4 +318,11 @@ class SampleZuulProxyApplication extends ZuulProxyTestBase.AbstractZuulProxyAppl
...
@@ -299,4 +318,11 @@ class SampleZuulProxyApplication extends ZuulProxyTestBase.AbstractZuulProxyAppl
}
}
}
}
static
class
MyRouteLocator
extends
DiscoveryClientRouteLocator
{
public
MyRouteLocator
(
String
servletPath
,
DiscoveryClient
discovery
,
ZuulProperties
properties
)
{
super
(
servletPath
,
discovery
,
properties
);
}
}
}
}
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