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:
committed by
Phillip Webb
parent
7299976d12
commit
bc55b6e0d4
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user