In Spring Data REST I'm creating custom links using a ResourceProcessor
:
@Component
public class ServiceInstanceProcessor
implements ResourceProcessor<Resource<ServiceInstance>> {
@Override
public Resource<ServiceInstance> process(Resource<ServiceInstance> resource) {
Long id = resource.getContent().getId();
ServiceInstanceController controller =
methodOn(ServiceInstanceController.class);
resource.add(linkTo(controller.getNodeSummary(id))
.withRel("nodeSummary"));
resource.add(linkTo(controller.getHealthBreakdown(id))
.withRel("healthBreakdown"));
resource.add(linkTo(controller.getRotationBreakdown(id))
.withRel("rotationBreakdown"));
return resource;
}
}
However the generated links don't include the base path, even though I've marked the controller as @BasePathAwareController
and even though the default links do include the base path:
{
...
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/serviceInstances/101"
},
"serviceInstance" : {
"href" : "http://localhost:8080/api/serviceInstances/101{?projection}",
"templated" : true
},
"nodeSummary" : {
"href" : "http://localhost:8080/serviceInstances/101/nodeSummary"
},
"healthBreakdown" : {
"href" : "http://localhost:8080/serviceInstances/101/healthBreakdown"
},
"rotationBreakdown" : {
"href" : "http://localhost:8080/serviceInstances/101/rotationBreakdown"
},
...
}
}
Is there anything else I need to do to get the base path to appear in the links?