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
7e91b9ea
Commit
7e91b9ea
authored
Dec 02, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename some Zuul config keys
zuul.route -> zuul.routes zuul.mapping -> zuul.prefix
parent
e272f8d6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
14 deletions
+29
-14
RouteLocator.java
.../org/springframework/cloud/netflix/zuul/RouteLocator.java
+2
-2
ZuulHandlerMapping.java
...pringframework/cloud/netflix/zuul/ZuulHandlerMapping.java
+2
-2
ZuulProperties.java
...rg/springframework/cloud/netflix/zuul/ZuulProperties.java
+3
-3
PreDecorationFilter.java
...k/cloud/netflix/zuul/filters/pre/PreDecorationFilter.java
+2
-2
RouteLocatorTests.java
...springframework/cloud/netflix/zuul/RouteLocatorTests.java
+17
-2
application.yml
spring-cloud-netflix-core/src/test/resources/application.yml
+3
-3
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/RouteLocator.java
View file @
7e91b9ea
...
...
@@ -44,7 +44,7 @@ public class RouteLocator implements ApplicationListener<EnvironmentChangeEvent>
@Override
public
void
onApplicationEvent
(
EnvironmentChangeEvent
event
)
{
for
(
String
key
:
event
.
getKeys
())
{
if
(
key
.
startsWith
(
properties
.
getMapping
()
))
{
if
(
key
.
startsWith
(
"zuul.route"
))
{
resetRoutes
();
return
;
}
...
...
@@ -90,7 +90,7 @@ public class RouteLocator implements ApplicationListener<EnvironmentChangeEvent>
}
protected
void
addConfiguredRoutes
(
Map
<
String
,
String
>
routes
)
{
Map
<
String
,
String
>
routeEntries
=
properties
.
getRoute
();
Map
<
String
,
String
>
routeEntries
=
properties
.
getRoute
s
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
routeEntries
.
entrySet
())
{
String
serviceId
=
entry
.
getKey
();
String
route
=
entry
.
getValue
()
;
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulHandlerMapping.java
View file @
7e91b9ea
...
...
@@ -58,8 +58,8 @@ public class ZuulHandlerMapping extends AbstractUrlHandlerMapping implements
url
=
"/"
+
url
;
}
if
(
StringUtils
.
hasText
(
properties
.
get
Mapping
()))
{
url
=
properties
.
get
Mapping
()
+
url
;
if
(
StringUtils
.
hasText
(
properties
.
get
Prefix
()))
{
url
=
properties
.
get
Prefix
()
+
url
;
if
(!
url
.
startsWith
(
"/"
))
{
url
=
"/"
+
url
;
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulProperties.java
View file @
7e91b9ea
...
...
@@ -15,9 +15,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties
(
"zuul"
)
public
class
ZuulProperties
{
private
String
mapping
=
""
;
private
boolean
strip
Mapping
=
false
;
private
Map
<
String
,
String
>
route
=
new
HashMap
<
String
,
String
>();
private
String
prefix
=
""
;
private
boolean
strip
Prefix
=
false
;
private
Map
<
String
,
String
>
route
s
=
new
HashMap
<
String
,
String
>();
private
boolean
addProxyHeaders
=
true
;
private
List
<
String
>
ignoredServices
=
Collections
.
emptyList
();
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre/PreDecorationFilter.java
View file @
7e91b9ea
...
...
@@ -57,10 +57,10 @@ public class PreDecorationFilter extends ZuulFilter {
String
requestURI
=
ctx
.
getRequest
().
getRequestURI
();
String
proxyMapping
=
properties
.
get
Mapping
();
String
proxyMapping
=
properties
.
get
Prefix
();
final
String
uriPart
;
if
(
StringUtils
.
hasText
(
proxyMapping
)
&&
properties
.
isStrip
Mapping
()
if
(
StringUtils
.
hasText
(
proxyMapping
)
&&
properties
.
isStrip
Prefix
()
&&
requestURI
.
startsWith
(
proxyMapping
))
{
// TODO: better strategy?
uriPart
=
requestURI
.
substring
(
proxyMapping
.
length
());
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/RouteLocatorTests.java
View file @
7e91b9ea
...
...
@@ -41,7 +41,22 @@ public class RouteLocatorTests {
public
void
testGetRoutes
()
{
ZuulProperties
properties
=
new
ZuulProperties
();
RouteLocator
routeLocator
=
new
RouteLocator
(
this
.
discovery
,
properties
);
properties
.
getRoute
().
put
(
ASERVICE
,
"/"
+
ASERVICE
+
"/**"
);
properties
.
getRoutes
().
put
(
ASERVICE
,
"/"
+
ASERVICE
+
"/**"
);
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
assertNotNull
(
"routesMap was null"
,
routesMap
);
assertFalse
(
"routesMap was empty"
,
routesMap
.
isEmpty
());
assertMapping
(
routesMap
,
ASERVICE
);
}
@Test
public
void
testGetRoutesWithMapping
()
{
ZuulProperties
properties
=
new
ZuulProperties
();
RouteLocator
routeLocator
=
new
RouteLocator
(
this
.
discovery
,
properties
);
properties
.
getRoutes
().
put
(
ASERVICE
,
"/"
+
ASERVICE
+
"/**"
);
// Prefix doesn't have any impact on the routes (it's used in the filter)
properties
.
setPrefix
(
"/foo"
);
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
...
...
@@ -54,7 +69,7 @@ public class RouteLocatorTests {
public
void
testGetPhysicalRoutes
()
{
ZuulProperties
properties
=
new
ZuulProperties
();
RouteLocator
routeLocator
=
new
RouteLocator
(
this
.
discovery
,
properties
);
properties
.
getRoute
().
put
(
"http://"
+
ASERVICE
,
"/"
+
ASERVICE
+
"/**"
);
properties
.
getRoute
s
().
put
(
"http://"
+
ASERVICE
,
"/"
+
ASERVICE
+
"/**"
);
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
...
...
spring-cloud-netflix-core/src/test/resources/application.yml
View file @
7e91b9ea
...
...
@@ -17,8 +17,8 @@ endpoints:
health
:
sensitive
:
false
zuul
:
#
mapping
: /api
#strip-
mapping
: true
route
:
#
prefix
: /api
#strip-
prefix
: true
route
s
:
testclient
:
/testing123/**
http://localhost:8081
:
/stores/**
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