I have a server REST API in java. The version 1.0 of the server code basically performed some functions and then use to return object of a class say X to client 1. Now in current version 2.0 same server code returns Response class object to client 2. Please note the API versioning is not done here. It is exactly the same code only difference is that some new features were added as server for client 2 didn't need some heavy features that were there in server 1. The issue is that I merging both 1.0 and 2.0 and creating a single binary. I have merged everything including functionality but the issue is in return types. Please note that url end point for all clients sides will be same and client side code can't be changed. Hence is there any way that this API can return two different response objects at run time according to the type of clients?? Also the server API can easily identify client type before returning the response but not when it gets the request.
Version 1 of server Code:
@POST
public T createOne(@BeanParam L locator, T item, @Context HttpServletRequest httpServletRequest, @Context HttpServletResponse httpServletResponse) { }
Version 2 of server code:
@POST
public Response createOne(@BeanParam L locator, T item, @Context HttpServletRequest httpServletRequest, @Context HttpServletResponse httpServletResponse) { }
Please note that the URI is exactly the same and I don't want to version it.