I have a RESTful service implemented in Jersey that consists of a top-level resource and many sub-resources. To illustrate:
Parent resource:
@Path("parent")
public class ParentResource {
private SubResourceA subResourceA;
private SubResourceB subResourceB;
private SubResourceC subResourceC;
public ParentResource() {
subResourceA = new SubResourceA();
subResourceB = new SubResourceB();
subResourceC = new SubResourceC();
}
@Path("a")
public SubResourceA getA() {
return subResourceA;
}
@Path("b")
public SubResourceB getB() {
return subResourceB;
}
@Path("c")
public SubResourceC getC() {
return subResourceC;
}
What I am looking for is to define a GET method on the ParentResource class that returns a link to all sub resources available in this class (similar to how on a file system if you select a folder which has folders inside of it, then you see the child folders).
Without such an implementation, if I hit GET /parent then I will get a 404 from my web service. Ideally GET /parent should give me a link to SubResourceA, SubResourceB and SubResourceC.
Is anyone aware of a standard convention for implementing such a feature? Specifically in JAX-RS/Jersey if possible.
Thanks