Add contextPath LocalHostUriTemplateHandler URIs

Update `LocalHostUriTemplateHandler` so that the `server.context-path`
property is also considered when building the URL.

Fixes gh-6904
Closes gh-6919
This commit is contained in:
Eddú Meléndez
2016-09-17 16:53:50 -05:00
committed by Phillip Webb
parent 7299976d12
commit bc55b6e0d4
4 changed files with 22 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
* @author Andy Wilkinson
* @author Eddú Meléndez
*/
public class LocalHostUriTemplateHandlerTests {
@@ -74,4 +75,13 @@ public class LocalHostUriTemplateHandlerTests {
assertThat(handler.getRootUri()).isEqualTo("https://localhost:8080");
}
@Test
public void getRootUriShouldUseContextPath() throws Exception {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("server.contextPath", "/foo");
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(
environment);
assertThat(handler.getRootUri()).isEqualTo("http://localhost:8080/foo");
}
}