Versioning with custom header or query param

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Versioning with custom header or query param

Darin Amos
Hello All,

I would like to add a customization to Apache Wink that allows me to use a query parameter or custom header for routing in order to implement versioning. After reviewing the code it appears the best way to do this would be to extend the ResourceRegistry class and override/extend the method: filterDispatchMethods(ResourceInstance, List<? extends MethodRecord>,RuntimeContext)

It appears the only way to do this would be to extend DeploymentConfiguration.initRegistries() by throwing away the instance of ResourceRegistry that is created, replacing it with my own instance.

Does anyone have any thoughts or suggestions on a better way to do this?

Thanks!

Darin


Reply | Threaded
Open this post in threaded view
|

Re: Versioning with custom header or query param

Anuj Bhatia
Hello Darin,

I tried something similar earlier, but instead of making any modifications to the JAX-RS implementation, we relied on creating a custom servlet for the routing logic. 

Basically the approach my project took was to have each version of the JAX-RS endpoints exposed at a different URL, like for example .../v1.0/myapi and ../v1.0/myapi and another servlet listening on .../myapi that would 'forward' the servlet request to the correct version based on the custom HTTP header.

Later we realized that it was much easier to just ask clients to directly call the versioned URL instead of sending a custom HTTP header and going via the routing servlet. :-)

Thanks
Anuj


On Fri, Jun 10, 2016 at 9:05 PM Darin Amos <[hidden email]> wrote:
Hello All,

I would like to add a customization to Apache Wink that allows me to use a query parameter or custom header for routing in order to implement versioning. After reviewing the code it appears the best way to do this would be to extend the ResourceRegistry class and override/extend the method: filterDispatchMethods(ResourceInstance, List<? extends MethodRecord>,RuntimeContext)

It appears the only way to do this would be to extend DeploymentConfiguration.initRegistries() by throwing away the instance of ResourceRegistry that is created, replacing it with my own instance.

Does anyone have any thoughts or suggestions on a better way to do this?

Thanks!

Darin


Reply | Threaded
Open this post in threaded view
|

Re: Versioning with custom header or query param

awardxclusive
This post has NOT been accepted by the mailing list yet.
In reply to this post by Darin Amos
Reply | Threaded
Open this post in threaded view
|

Re: Versioning with custom header or query param

Jaybliss
This post has NOT been accepted by the mailing list yet.
In reply to this post by Darin Amos
Oh my goodness, This forum is so beautiful  and functional who designed this site? I swear, if the owner can employ admins like me, this forum will be better than Nairaland


Admin.  please I don't understand what mailing list is or means here.


Feat mp3