Fix prefix issue
This commit is contained in:
@@ -81,6 +81,9 @@ public class FunctionHandlerMapping extends RequestMappingHandlerMapping
|
|||||||
}
|
}
|
||||||
String path = (String) request
|
String path = (String) request
|
||||||
.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
|
.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
|
||||||
|
if (path.startsWith(prefix)) {
|
||||||
|
path = path.substring(prefix.length());
|
||||||
|
}
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class PrefixTests {
|
|||||||
@Test
|
@Test
|
||||||
public void words() throws Exception {
|
public void words() throws Exception {
|
||||||
ResponseEntity<String> result = rest
|
ResponseEntity<String> result = rest
|
||||||
.exchange(RequestEntity.get(new URI("/words")).build(), String.class);
|
.exchange(RequestEntity.get(new URI("/functions/words")).build(), String.class);
|
||||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(result.getBody()).isEqualTo("foobar");
|
assertThat(result.getBody()).isEqualTo("foobar");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user