Introduce Traverson as means to traverse hypermedia based APIs by providing a set of relation names to discover and follow to access the final representation. Traverson allows to specify a parameter map that will be used to potentially expand the URIs discovered.
We currently support LinkDiscoverer based relation discovery, which means that relations in HAL representations can be found by simply stating their names. Alternatively JSON path expressions can be used (starting with a $).
ControllerLinkBuilder(Factory) now has a linkTo(Method method, Object… parameters) and linkTo(Object dummyMethodInvocationResult) method to either inspect the given method or the result of the dummy method invocation that can be created through DummyInvocationUtils.methodOn(…). So for the following controller:
@Controller
@RequestMapping("/people")
class PersonController {
@RequestMapping(value = "/{person}", method = RequestMethod.GET)
public HttpEntity<PersonResource> show(@PathVariable Long person) { … }
}
you could now do:
Link link = linkTo(methodOn(PersonController.class).show(2L)).withSelfRel();
assertThat(link.getHref(), is("/people/2")));
The code is highly inspired by the code Dietrich Schulten (@dschulten) provided in his pull requests but radically reduced to the core functionality. I also didn't add support for JAX-RS in the first place, but this is definitely a topic going forward.