spring-hateoas
spring-hateoas copied to clipboard
LinkBuilder doesn't include Matrix Variables
If an endpoint uses Matrix Variables and you try to create a link to this method, the passed matrix variables aren't inserted into the link. The issue popped up in this Stack Overflow question.
See the following endpoint as an example:
@RequestMapping(value = "/matrix", method = RequestMethod.GET)
public HttpEntity> example(
@MatrixVariable String first,
@MatrixVariable(required = false) String second) {
return new HttpEntity("first=" + first + " second=" + second);
}
Using linkTo(methodOn(MvcController.class).example("First", "Second")).withSelfRel().getHref(); produces http://localhost:8090/matrix
whereas it should be http://localhost:8090/matrix;first=First;second=Second
As I outlined in the SO answer it is most likely that the UriBuilder implementation just doesn't consider matrix parameters:
- See this part of the UriTemplate. It uses different variable types to build the Uri. A matrix parameter isn't one of them.
- See the VariableType enum, which was used to do the switch on. There is also no matrix param.
There should be a possibility to create links with matrix variables.
Hey Dennis, Did you find any solution for this? I am running into same issue, i was not able to generate the link as I am using matrix variables in my endpoint.
Please fix this. I need it.