-
Notifications
You must be signed in to change notification settings - Fork 141
Open
Description
Request mapping only takes into account the number of path chunks (the number of slashes in the url) when finding the corresponding java method to call. It means that the two urls like
"/services/test/projects/1/files/2" and "/services/test/projects/1/images/3" are mapped to the same method. I created a simple test :
public class Test {
@RequestMapping("/projects/{projectId}/files/{fileId}")
public String test1(@PathVariable("projectId") int projectId, @PathVariable("fileId") int fileId) {
return "test1";
}
@RequestMapping("/projects/{projectId}/images/{imageId}")
public String test2(@PathVariable("projectId") int projectId, @PathVariable("imageId") int imageId) {
return "test2";
}
public static void main(String[] args) {
final ManagedServiceBuilder managedServiceBuilder = ManagedServiceBuilder.managedServiceBuilder().setRootURI("/services").setPort(2334);
managedServiceBuilder.addEndpointService("test", new Test());
EndpointServerBuilder builder = managedServiceBuilder.getEndpointServerBuilder();
ServiceEndpointServer server = builder.build();
server.startServer();
HttpClient tmService = HttpClientBuilder.httpClientBuilder().setHost("localhost").setPort(2334).build();
tmService.startClient();
System.out.println(tmService.get("/services/test/projects/1/files/2"));
System.out.println(tmService.get("/services/test/projects/1/images/3"));
}
}
If you run the test, you'll get:
HttpTextResponse(code:200contentType:application/json
body:
"test1"
)
HttpTextResponse(code:200contentType:application/json
body:
"test1"
)
The first method is called in both cases, which is incorrect.
Metadata
Metadata
Assignees
Labels
No labels