Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect request mapping #779

Open
ArtemBudnikov opened this issue Nov 24, 2017 · 0 comments
Open

incorrect request mapping #779

ArtemBudnikov opened this issue Nov 24, 2017 · 0 comments

Comments

@ArtemBudnikov
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant