This can be done by implementing ResourceProcessor<RepositoryLinksResource>
.
Following code snippet adds "/others" to the root listing
@Controller
@ExposesResourceFor(Other.class)
@RequestMapping("/others")
public class CustomRootController implements
ResourceProcessor<RepositoryLinksResource> {
@ResponseBody
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Resources<Resource<Other>>> listEntities(
Pageable pageable) throws ResourceNotFoundException {
//... do what needs to be done
}
@Override
public RepositoryLinksResource process(RepositoryLinksResource resource) {
resource.add(ControllerLinkBuilder.linkTo(CustomRootController.class).withRel("others"));
return resource;
}
}
should add
{
"rel": "others",
"href": "http://localhost:8080/api/others"
}
to your root listing links