[Catalyst] REST and versioning

Bill Moseley moseley at hank.org
Tue Sep 17 14:52:55 GMT 2013


I've once again used up an hour or so reading Stack Overflow and blog posts
on REST API versioning.   (And the arguments for and against.)

Perhaps extending the discussion on how Catalyst supports REST:

https://github.com/perl-catalyst/CatalystX-Proposals-REStandContentNegotiat=
ion

I'm wondering if Catalyst might help in supporting API versions.  Somewhat
similar to how Catalyst::Action::REST will call methods based on the HTTP
method, perhaps call actions based on some version (provided by some means
-- like a version in the path or in an Accept header).

Catalyst::Action::REST helps keep the actions tidy by calling methods
specific to each method  (foo_GET, foo_PUT).  Obviously, we could simply
check if ( $req->method eq 'GET' ) but would end up with pretty ugly
actions and no automatic "Allow" header.

With versions I'm concerned about that my foo_GET method will end up with a
bunch of "if ( $version > 1.1 ) {....} elsif ($version >1.0 ) ...

So, running with the C::Action::REST approach, something like:

sub foo_GET { ... }  # Default
sub foo_GET : Version( 1.1 ) { ... }  # Use if client requests version is
1.1

Frankly, seems like maintenance nightmare and Action explosion.   Where
that version comes from (url, Accpet header) is often debated (see links).


Any better ideas how to support versioning in Catalyst actions?



The subject of versioning is a bit overwhelming.  Here's some starting
points, if curious:


   -
   http://stackoverflow.com/questions/389169/best-practices-for-api-version=
ing
   -
   http://www.lexicalscope.com/blog/2012/03/12/how-are-rest-apis-versioned/
   - http://www.subbu.org/blog/2008/05/avoid-versioning-please
   -
   http://stackoverflow.com/questions/2024600/rest-api-versioning-only-vers=
ion-the-representation-not-the-resource-itself?lq=3D1
   - http://www.informit.com/articles/article.aspx?p=3D1566460
   - http://stackoverflow.com/questions/972226/how-to-version-rest-uris
   - and plenty more...



-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20130917/3de26=
5ff/attachment.htm


More information about the Catalyst mailing list