-
Feature Request
-
Resolution: Done
-
Major
-
2.2.2.GA
-
None
In the current implementation of client proxies, ProxyFactory.create() will throw if it encounters a method that has no HTTP method annotation associated with it (@GET, @POST, etc). However, elsewhere in the RESTEasy documentation, sub-resource accessor methods are described specifically as being annotated with @Path, but not with an HTTP method annotation. This indicates that these methods are navigational and the returned type is expected to be another appropriately annotated resource class.
In the client, it seems like it would make sense that the generated proxies could return new proxies instantiated based on the context passed in the method arguments. While the actual concrete return type of these methods need not be specified, the proxy could return an object of the type specified in the method declaration.
By way of example, consder the following two Service interfaces
public interface Book { @GET @Path("/title") String getTitle() @Path("{number}") Chapter getChapter(@PathParam("number") int number) } public interface Chapter { @GET @Path("title") public String getTitle(); @GET @Path("body") public String getBody(); }
Once the Book service has been created, one could then invoke the getChapter() method to get an instance of the Chapter service interface pointed at a particular chapter.
It seems this could be done entirely on the client side without any REST calls as all of the information is available in the method invocation. The proxy would respond by creating a new proxy to the Chapter interface using the "number" parameter to complete the URI.
I have an implementation of this in the resteasy codebase and would be happy to submit a patch.