Hi
On 07/10/14 18:19, Duncan Keysell (dkeysell) wrote:
Hi,
I have the requirement to support versioning on my REST API in a legacy
application I have inherited. I have to implement the versioning of the
resources via a version segment of the URL, as that is what we have advertised
we are doing. e.g. /myRoot/v1/myResource and /myRoot/v2/myResource. Currently
my REST API has the following config (I.e. Everything is hardcoded to appear at
v1):
<jaxrs:server id="myService" address="/v1" name="myService">
…
</jaxrs:server>
I have updated by serviceBeans so that they now expect to receive the /v[0-9]+
segment as a path parameter:
@Path("/{version:v[0-9]+}/myResource")
And for that to work I have to move my jaxrs:server to the address="/"
However I have found there is already another jaxrs:server with address="/"
I don't want to mix my serviceBean with the one already sitting on "/" as both
of us have interceptors and providers not suitable to each other. Also I don't want to
change the URLs of any of the resources as this will break clients..
Is there any solution to this dilemma?
If you already have the existing endpoint on "/" then I'd consider just
keep adding "/v1", "/v2" endpoints, sharing the service bean between
them if needed. And that would also let you have different providers
between different versions if needed which is not possible otherwise.
IMHO it also makes sense to avoid having endpoints with over-lapping
addresses, may make sense to migrate a "/" endpoint to something more
specific
Cheers, Sergey
Thanks
Duncan