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
243e163d
Commit
243e163d
authored
Nov 26, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add JMX and MVC endpoints to ZuulHandlerMapping
User can now list routes with /zuul/routes and reset with a POST. Fixes gh-75
parent
05fe1752
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
3 deletions
+48
-3
ZuulHandlerMapping.java
...pringframework/cloud/netflix/zuul/ZuulHandlerMapping.java
+48
-3
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulHandlerMapping.java
View file @
243e163d
...
...
@@ -3,15 +3,28 @@ package org.springframework.cloud.netflix.zuul;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint
;
import
org.springframework.cloud.client.discovery.InstanceRegisteredEvent
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.jmx.export.annotation.ManagedAttribute
;
import
org.springframework.jmx.export.annotation.ManagedOperation
;
import
org.springframework.jmx.export.annotation.ManagedResource
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
;
/**
* MVC HandlerMapping that maps incoming request paths to remote services.
*
* @author Spencer Gibb
* @author Dave Syer
*/
public
class
ZuulHandlerMapping
extends
AbstractUrlHandlerMapping
implements
ApplicationListener
<
InstanceRegisteredEvent
>
{
@ManagedResource
(
description
=
"Can be used to list and reset the reverse proxy routes"
)
public
class
ZuulHandlerMapping
extends
AbstractUrlHandlerMapping
implements
ApplicationListener
<
InstanceRegisteredEvent
>,
MvcEndpoint
{
private
RouteLocator
routeLocator
;
...
...
@@ -20,7 +33,8 @@ public class ZuulHandlerMapping extends AbstractUrlHandlerMapping implements App
private
ZuulProperties
properties
;
@Autowired
public
ZuulHandlerMapping
(
RouteLocator
routeLocator
,
ZuulController
zuul
,
ZuulProperties
properties
)
{
public
ZuulHandlerMapping
(
RouteLocator
routeLocator
,
ZuulController
zuul
,
ZuulProperties
properties
)
{
this
.
routeLocator
=
routeLocator
;
this
.
zuul
=
zuul
;
this
.
properties
=
properties
;
...
...
@@ -45,7 +59,7 @@ public class ZuulHandlerMapping extends AbstractUrlHandlerMapping implements App
}
if
(
StringUtils
.
hasText
(
properties
.
getRoutePrefix
()))
{
url
=
properties
.
getMapping
()+
url
;
url
=
properties
.
getMapping
()
+
url
;
if
(!
url
.
startsWith
(
"/"
))
{
url
=
"/"
+
url
;
}
...
...
@@ -56,4 +70,35 @@ public class ZuulHandlerMapping extends AbstractUrlHandlerMapping implements App
}
}
@RequestMapping
(
value
=
"routes"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
@ManagedOperation
public
Map
<
String
,
String
>
reset
()
{
Map
<
String
,
String
>
routes
=
routeLocator
.
getRoutes
();
registerHandlers
(
routes
);
return
routes
;
}
@RequestMapping
(
value
=
"routes"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
@ManagedAttribute
public
Map
<
String
,
String
>
getRoutes
()
{
return
routeLocator
.
getRoutes
();
}
@Override
public
String
getPath
()
{
return
"/proxy"
;
}
@Override
public
boolean
isSensitive
()
{
return
true
;
}
@Override
public
Class
<?
extends
Endpoint
<?>>
getEndpointType
()
{
return
null
;
}
}
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