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
11201762
Commit
11201762
authored
Dec 29, 2014
by
Julien Roy
Committed by
Dave Syer
Jan 02, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eureka dashboard controller path mapping can be configured or disabled
parent
8f8e738f
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
147 additions
and
7 deletions
+147
-7
EurekaController.java
...amework/cloud/netflix/eureka/server/EurekaController.java
+8
-2
EurekaServerConfiguration.java
...loud/netflix/eureka/server/EurekaServerConfiguration.java
+3
-1
header.ftl
...eka-server/src/main/resources/templates/eureka/header.ftl
+4
-3
wro.xml
spring-cloud-netflix-eureka-server/src/main/wro/wro.xml
+2
-1
ApplicationContextTests.java
.../cloud/netflix/eureka/server/ApplicationContextTests.java
+7
-0
ApplicationDashboardDisabledTests.java
...flix/eureka/server/ApplicationDashboardDisabledTests.java
+44
-0
ApplicationDashboardPathTests.java
.../netflix/eureka/server/ApplicationDashboardPathTests.java
+72
-0
ApplicationServletPathTests.java
...ud/netflix/eureka/server/ApplicationServletPathTests.java
+7
-0
No files found.
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java
View file @
11201762
...
...
@@ -12,6 +12,7 @@ import com.netflix.eureka.resources.StatusResource;
import
com.netflix.eureka.util.StatusInfo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -26,12 +27,16 @@ import java.util.*;
* @author Spencer Gibb
*/
@Controller
@RequestMapping
(
"${eureka.dashboard.path:/}"
)
public
class
EurekaController
{
@Autowired
@Value
(
"${eureka.dashboard.path:/}"
)
private
String
dashboardPath
=
""
;
@Autowired
ServerProperties
serverProperties
;
@RequestMapping
(
value
=
"/"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
method
=
RequestMethod
.
GET
)
public
String
status
(
HttpServletRequest
request
,
Map
<
String
,
Object
>
model
)
{
populateBase
(
request
,
model
);
...
...
@@ -86,6 +91,7 @@ public class EurekaController {
model
.
put
(
"time"
,
new
Date
());
model
.
put
(
"basePath"
,
basePath
);
model
.
put
(
"dashboardPath"
,
dashboardPath
);
populateHeader
(
model
);
...
...
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java
View file @
11201762
...
...
@@ -3,6 +3,7 @@ package org.springframework.cloud.netflix.eureka.server;
import
javax.servlet.Filter
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.embedded.FilterRegistrationBean
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.netflix.eureka.EurekaServerConfigBean
;
...
...
@@ -26,6 +27,7 @@ import com.sun.jersey.spi.container.servlet.ServletContainer;
public
class
EurekaServerConfiguration
extends
WebMvcConfigurerAdapter
{
@Bean
@ConditionalOnProperty
(
prefix
=
"eureka.dashboard"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
public
EurekaController
eurekaController
()
{
return
new
EurekaController
();
}
...
...
@@ -36,7 +38,7 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
bean
.
setFilter
(
new
ServletContainer
());
bean
.
setOrder
(
Ordered
.
LOWEST_PRECEDENCE
);
bean
.
addInitParameter
(
"com.sun.jersey.config.property.WebPageContentRegex"
,
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/(fonts|images|css)/.*"
);
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/(fonts|images|css
|js
)/.*"
);
bean
.
addInitParameter
(
"com.sun.jersey.config.property.packages"
,
"com.netflix.discovery;com.netflix.eureka"
);
bean
.
setUrlPatterns
(
Lists
.
newArrayList
(
EurekaServerConfigBean
.
DEFAULT_PREFIX
...
...
spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/header.ftl
View file @
11201762
<#import "/spring.ftl" as spring />
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="
${basePath}
"><span></span></a>
<a class="navbar-brand" href="
<@spring.url dashboardPath/>
"><span></span></a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
...
...
@@ -12,10 +13,10 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="
${basePath}
">Home</a>
<a href="
<@spring.url dashboardPath/>
">Home</a>
</li>
<li>
<a href="lastn">Last 1000 since startup</a>
<a href="
<@spring.url dashboardPath/>/
lastn">Last 1000 since startup</a>
</li>
</ul>
</div>
...
...
spring-cloud-netflix-eureka-server/src/main/wro/wro.xml
View file @
11201762
...
...
@@ -3,6 +3,6 @@
<css>
webjar:bootstrap/3.2.0/less/bootstrap.less
</css>
<css>
file:${project.basedir}/src/main/wro/main.less
</css>
<js>
webjar:jquery/2.1.1/jquery.min.js
</js>
<js>
webjar:bootstrap/3.2.0/
bootstrap
.js
</js>
<js>
webjar:bootstrap/3.2.0/
js/bootstrap.min
.js
</js>
</group>
</groups>
\ No newline at end of file
spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationContextTests.java
View file @
11201762
...
...
@@ -70,6 +70,13 @@ public class ApplicationContextTests {
}
@Test
public
void
jsAvailable
()
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/context/eureka/js/wro.js"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
}
@Test
public
void
adminLoads
()
{
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
...
...
spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationDashboardDisabledTests.java
0 → 100644
View file @
11201762
package
org
.
springframework
.
cloud
.
netflix
.
eureka
.
server
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.cloud.netflix.eureka.server.ApplicationContextTests.Application
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
java.util.Map
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Application
.
class
)
@WebAppConfiguration
@IntegrationTest
({
"server.port=0"
,
"spring.application.name=eureka"
,
"eureka.dashboard.enabled=false"
})
public
class
ApplicationDashboardDisabledTests
{
@Value
(
"${local.server.port}"
)
private
int
port
=
0
;
@Test
public
void
catalogLoads
()
{
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/eureka/apps"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
}
@Test
public
void
dashboardLoads
()
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/"
,
String
.
class
);
assertEquals
(
HttpStatus
.
NOT_FOUND
,
entity
.
getStatusCode
());
}
}
spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationDashboardPathTests.java
0 → 100644
View file @
11201762
package
org
.
springframework
.
cloud
.
netflix
.
eureka
.
server
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.cloud.netflix.eureka.server.ApplicationContextTests.Application
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
java.util.Map
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Application
.
class
)
@WebAppConfiguration
@IntegrationTest
({
"server.port=0"
,
"spring.application.name=eureka"
,
"eureka.dashboard.path=/dashboard"
})
public
class
ApplicationDashboardPathTests
{
@Value
(
"${local.server.port}"
)
private
int
port
=
0
;
@Test
public
void
catalogLoads
()
{
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/eureka/apps"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
}
@Test
public
void
dashboardLoads
()
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/dashboard"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
String
body
=
entity
.
getBody
();
// System.err.println(body);
assertTrue
(
body
.
contains
(
"eureka/js"
));
assertTrue
(
body
.
contains
(
"eureka/css"
));
// The "DS Replicas"
assertTrue
(
body
.
contains
(
"<a href=\"http://localhost:8761/eureka/\">localhost</a>"
));
// The Home
assertTrue
(
body
.
contains
(
"<a href=\"/dashboard\">Home</a>"
));
// The Lastn
assertTrue
(
body
.
contains
(
"<a href=\"/dashboard/lastn\">Last"
));
}
@Test
public
void
cssAvailable
()
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/eureka/css/wro.css"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
}
@Test
public
void
jsAvailable
()
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/eureka/js/wro.js"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
}
}
spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationServletPathTests.java
View file @
11201762
...
...
@@ -70,6 +70,13 @@ public class ApplicationServletPathTests {
}
@Test
public
void
jsAvailable
()
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/servlet/eureka/js/wro.js"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
}
@Test
public
void
adminLoads
()
{
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
...
...
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