Commit a0ffe33a by Johannes Edmeier

Consider servlet-path for guessing management-url

Take the servlet-path into account when computing the management-/healht-url. This is not done for the service-url, since the main use-case for setting the servlet-path is to get the dispatcher-servlet out of the way for other servlets. fixes #133
parent 1923b404
...@@ -209,7 +209,7 @@ spring.boot.admin.password ...@@ -209,7 +209,7 @@ spring.boot.admin.password
| spring.boot.admin.client.management-url | spring.boot.admin.client.management-url
| Client-management-url to register with. Can be overriden in case the reachable url is different (e.g. Docker). | Client-management-url to register with. Can be overriden in case the reachable url is different (e.g. Docker).
| Guessed based on service-url, `management.port` and `management.context-path`. | Guessed based on service-url, `server.servlet-path`, `management.port` and `management.context-path`.
| spring.boot.admin.client.service-url | spring.boot.admin.client.service-url
| Client-service-url to register with. Can be overriden in case the reachable url is different (e.g. Docker). | Client-service-url to register with. Can be overriden in case the reachable url is different (e.g. Docker).
......
...@@ -94,7 +94,8 @@ public class AdminClientProperties { ...@@ -94,7 +94,8 @@ public class AdminClientProperties {
if ((managementPort == null || managementPort.equals(serverPort)) if ((managementPort == null || managementPort.equals(serverPort))
&& getServiceUrl() != null) { && getServiceUrl() != null) {
return append(getServiceUrl(), management.getContextPath()); return append(append(getServiceUrl(), server.getServletPrefix()),
management.getContextPath());
} }
if (ready && managementPort == null) { if (ready && managementPort == null) {
......
...@@ -91,6 +91,21 @@ public class AdminClientPropertiesTest { ...@@ -91,6 +91,21 @@ public class AdminClientPropertiesTest {
} }
@Test @Test
public void test_servletPath() {
load("server.servlet-path=app", "server.context-path=srv", "local.server.port=80");
AdminClientProperties clientProperties = new AdminClientProperties();
context.getAutowireCapableBeanFactory().autowireBean(clientProperties);
publishApplicationReadyEvent(clientProperties);
assertThat(clientProperties.getManagementUrl(),
is("http://" + getHostname() + ":80/srv/app"));
assertThat(clientProperties.getHealthUrl(),
is("http://" + getHostname() + ":80/srv/app/health"));
assertThat(clientProperties.getServiceUrl(), is("http://" + getHostname() + ":80/srv"));
}
@Test
public void test_default() { public void test_default() {
load("local.server.port=8080"); load("local.server.port=8080");
AdminClientProperties clientProperties = new AdminClientProperties(); AdminClientProperties clientProperties = new AdminClientProperties();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment