release 2.2

1 view
Skip to first unread message

t

unread,
Mar 6, 2010, 5:09:12 PM3/6/10
to fulworx-dev
For a while I've been bothered by how fulwox deals with versioning
(or, more to the point, doesn't). Putting a version id in a URI is
not restful in the pure sense, and this should be dealt with using
media types.

With release 2.2, this is now possible. For instance, assume I have a
URI "/app/user/{id}" that retrieves a user xml representation with an
id {id}. If I change that xml, I may be tempted to change the URI to
something like "/app/user/v2/{id}", but that's changed my uri and has
broken my resource. Instead I can add "application/xml; version=2.0"
as a media type.

I'd still deploy both actions, so users of the previous resource can
still use it, but the newer version can be accessed with the same
resource.

Versions are only one example of using a media type. You could deploy
other actual types (html, images, etc) to the same uri and just change
the media type to access them.

See http://code.google.com/p/fulworx/wiki/V2p2Documentation#URI_Templates
for more information.

T

Matt Darling

unread,
Mar 7, 2010, 2:13:42 PM3/7/10
to fulwo...@googlegroups.com
Might this approach also make accessing a specific return type better.
Meaning rather than access the uri with .json, you could ask for it
with the media type application/json.

This is great though for versioning!!

Sent from my iPhone

> --
> You received this message because you are subscribed to the Google
> Groups "fulworx-dev" group.
> To post to this group, send email to fulwo...@googlegroups.com.
> To unsubscribe from this group, send email to fulworx-dev...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/fulworx-dev?hl=en
> .
>

t

unread,
Mar 7, 2010, 2:42:50 PM3/7/10
to fulworx-dev
Absolutely. You just need to code your own representation builder
(that is something that the 2.x release allows). So the combination
of the two really makes the resource media agnostic. Naturally
the .json, .xml, etc. is still supported, but it's no longer
necessary.

In fact the documentation on the URITemplate does specifically mention
other types (for instance, atom+xml), but I've been mostly vexed with
the versioning and that was the main driver (for me).

T

On Mar 7, 11:13 am, Matt Darling <mdarl...@gmail.com> wrote:
> Might this approach also make accessing a specific return type better.
> Meaning rather than access the uri with .json, you could ask for it
> with the media type application/json.
>
> This is great though for versioning!!
>
> Sent from my iPhone
>

> On Mar 6, 2010, at 14:09, t <teastl...@gmail.com> wrote:
>
> > For a while I've been bothered by how fulwox deals with versioning
> > (or, more to the point, doesn't).  Putting a version id in a URI is
> > not restful in the pure sense, and this should be dealt with using
> > media types.
>
> > With release 2.2, this is now possible.  For instance, assume I have a
> > URI "/app/user/{id}" that retrieves a user xml representation with an
> > id {id}.  If I change that xml, I may be tempted to change the URI to
> > something like "/app/user/v2/{id}", but that's changed my uri and has
> > broken my resource.  Instead I can add "application/xml; version=2.0"
> > as a media type.
>
> > I'd still deploy both actions, so users of the previous resource can
> > still use it, but the newer version can be accessed with the same
> > resource.
>
> > Versions are only one example of using a media type.  You could deploy
> > other actual types (html, images, etc) to the same uri and just change
> > the media type to access them.
>

> > Seehttp://code.google.com/p/fulworx/wiki/V2p2Documentation#URI_Templates

t

unread,
Mar 7, 2010, 3:51:06 PM3/7/10
to fulworx-dev
I've explicitly broken out these representation builders if you want,
see http://code.google.com/p/fulworx/wiki/V2p2Documentation#Accessor

This lets you specify something like:
@URITemplate(uri = "/resource/{param}", mediaType = "application/json;
version=2.0")
@Accessor("entity", builderClass=JSONRepresentationBuilder.class)

now this resource will always return json. I will look into doing
this automatically based on the mediaType above (will only really work
for xml, json, xsd).

T

t

unread,
Mar 7, 2010, 7:11:24 PM3/7/10
to fulworx-dev
Alright. you ask and you get :)

I've included some rules around media type conversion:
If you don't specify a media type, all requests will find it.
If you do specify a media type, only matching requests will find it
If your media type is 'application/xml', all requests will find it
(this is a secondary default)
If you have a media type with other information (like a version) and
the type is 'application/xml', all requests will find it if their
other information matches (this allows for json/xsd transforms against
xml)

T

On Mar 7, 11:13 am, Matt Darling <mdarl...@gmail.com> wrote:

> Might this approach also make accessing a specific return type better.
> Meaning rather than access the uri with .json, you could ask for it
> with the media type application/json.
>
> This is great though for versioning!!
>
> Sent from my iPhone
>

> On Mar 6, 2010, at 14:09, t <teastl...@gmail.com> wrote:
>
> > For a while I've been bothered by how fulwox deals with versioning
> > (or, more to the point, doesn't).  Putting a version id in a URI is
> > not restful in the pure sense, and this should be dealt with using
> > media types.
>
> > With release 2.2, this is now possible.  For instance, assume I have a
> > URI "/app/user/{id}" that retrieves a user xml representation with an
> > id {id}.  If I change that xml, I may be tempted to change the URI to
> > something like "/app/user/v2/{id}", but that's changed my uri and has
> > broken my resource.  Instead I can add "application/xml; version=2.0"
> > as a media type.
>
> > I'd still deploy both actions, so users of the previous resource can
> > still use it, but the newer version can be accessed with the same
> > resource.
>
> > Versions are only one example of using a media type.  You could deploy
> > other actual types (html, images, etc) to the same uri and just change
> > the media type to access them.
>

> > Seehttp://code.google.com/p/fulworx/wiki/V2p2Documentation#URI_Templates

Reply all
Reply to author
Forward
0 new messages