tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Soto <asot...@gmail.com>
Subject Re: JaxRS versioning REST API
Date Mon, 20 Oct 2014 08:17:07 GMT
Yes I like the header approach as well, but then I see no way to implement
it directly using subresources.

2014-10-20 10:14 GMT+02:00 Romain Manni-Bucau <rmannibucau@tomitribe.com>:

> most of real impl uses path (/v1) but i like header solution. allows
> to handle default correctly without rewrite magic and to add it for v2
> once forgotten for v1 :)
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-10-20 10:10 GMT+02:00 Jean-Louis Monteiro <jlmonteiro@tomitribe.com>:
> > Right. No magic solution.
> >
> > I've seen the content type pattern, but it has many drawbacks so I would
> > not go with this one.
> >
> > --
> > Jean-Louis Monteiro
> > http://twitter.com/jlouismonteiro
> > http://www.tomitribe.com
> >
> > On Sun, Oct 19, 2014 at 1:48 PM, Alex Soto <asotobu@gmail.com> wrote:
> >
> >> Yes this is what I though about creating a central place, but I was
> >> thinking about using a rewrite instead of a subresource. I am going to
> >> google a bit about this pattern. For what I see there is no magic
> solution
> >> yet :(
> >>
> >> Thanks.
> >>
> >> 2014-10-19 13:44 GMT+02:00 Romain Manni-Bucau <
> rmannibucau@tomitribe.com>:
> >>
> >> > Hi
> >> >
> >> > What about sub resource locator pattern?
> >> >
> >> > For versioning I used a sub resource facade delegating to the real
> >> > service then. This is just a router but it allows to put all the logic
> >> > in a single place.
> >> > Romain Manni-Bucau
> >> > Twitter: @rmannibucau
> >> > Blog: http://rmannibucau.wordpress.com/
> >> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >> > Github: https://github.com/rmannibucau
> >> >
> >> >
> >> >
> >> > 2014-10-19 13:19 GMT+02:00 Alex Soto <asotobu@gmail.com>:
> >> > > Hi guys,
> >> > >
> >> > > this is more a design question than a question about how to do
> >> something
> >> > > with JAX-RS.
> >> > >
> >> > > Currently I am developing an API using JAX-RS which must be
> >> versionable.
> >> > > That means that the API will evolve and client must specify which
> >> version
> >> > > of the API want to use. There are a lot of strategies but finally
I
> >> > decided
> >> > > to use the one using Header and ContentType. Let me show an example:
> >> > >
> >> > > @Consumes*({*"application/vnd.blog.v1+xml"*,*
> >> > "application/vnd.blog.v1+json"
> >> > > *})*
> >> > >
> >> > > @Produces*({*"application/vnd.blog.v1+xml"*,*
> >> > "application/vnd.blog.v1+json"
> >> > > *})*
> >> > >
> >> > > *public* *class* Book*RestfulService* *{*
> >> > >
> >> > >
> >> > >
> >> > >     @GET
> >> > >
> >> > >     @Path*(*"/books"*)*
> >> > >
> >> > >    ….
> >> > >
> >> > > }
> >> > >
> >> > > @Consumes*({*"application/vnd.blog.v1+xml"*,*
> >> > "application/vnd.blog.v1+json"
> >> > > *})*
> >> > >
> >> > > @Produces*({*"application/vnd.blog.v1+xml"*,*
> >> > "application/vnd.blog.v1+json"
> >> > > *})*
> >> > >
> >> > > *public* *class* Author*RestfulService* *{*
> >> > >
> >> > >
> >> > >
> >> > >     @GET
> >> > >
> >> > >     @Path*(*“/authors”*)*
> >> > >
> >> > >    ….
> >> > >
> >> > > }
> >> > >
> >> > > That's an example of version one, but now let's say I have a
> >> modification
> >> > > only in Author endpoint. I can do it and then the restful will be
> v2.
> >> So
> >> > I
> >> > > will have something like:
> >> > >
> >> > > @Consumes*({*"application/vnd.blog.v2+xml"*,*
> >> > "application/vnd.blog.v2+json"
> >> > > *})*
> >> > >
> >> > > @Produces*({*"application/vnd.blog.v2+xml"*,*
> >> > "application/vnd.blog.v2+json"
> >> > > *})*
> >> > >
> >> > > *public* *class* Author2*RestfulService* *{*
> >> > >
> >> > >
> >> > >
> >> > >     @GET
> >> > >
> >> > >     @Path*(*“/authors”*)*
> >> > >
> >> > >    ….
> >> > >
> >> > > }
> >> > > The problem is that because Book has not received any modification,
> I
> >> > > should add @Consumes and @Produces with v2 as well, something like:
> >> > >
> >> > > @Consumes*({*"application/vnd.blog.v1+xml"*,*
> >> > "application/vnd.blog.v1+json",
> >> > > "application/vnd.blog.v2+xml"*,* "application/vnd.blog.v2+json"*})*
> >> > >
> >> > > @Produces*({*"application/vnd.blog.v1+xml"*,*
> >> > "application/vnd.blog.v1+json",
> >> > > ....*})*
> >> > >
> >> > > *public* *class* Book*RestfulService* *{*
> >> > >
> >> > > *}*
> >> > >
> >> > > So now it is easy but if I have 25 services then I would need to go
> one
> >> > by
> >> > > one and add the media type as well. The problem is that I can miss
> one
> >> > and
> >> > > then the API had a misplaced endpoint.
> >> > >
> >> > > One thing that I have thought about it is create a rewriting filter
> >> > where I
> >> > > can intercept the calls and then redirect to the correct endpoint.
> In
> >> > this
> >> > > way all the rules will be placed in a single place.
> >> > >
> >> > > Any hints/experience on this?
> >> > >
> >> > > Thank you so much.
> >> > >
> >> > >
> >> > > --
> >> > > +----------------------------------------------------------+
> >> > >   Alex Soto Bueno
> >> > >   www.lordofthejars.com
> >> > > +----------------------------------------------------------+
> >> >
> >>
> >>
> >>
> >> --
> >> +----------------------------------------------------------+
> >>   Alex Soto Bueno - Computer Engineer
> >>   www.lordofthejars.com
> >> +----------------------------------------------------------+
> >>
>



-- 
+----------------------------------------------------------+
  Alex Soto Bueno - Computer Engineer
  www.lordofthejars.com
+----------------------------------------------------------+

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message