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-REStandContentNegotiation 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-versioning - 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-version-the-representation-not-the-resource-itself?lq=1 - http://www.informit.com/articles/article.aspx?p=1566460 - http://stackoverflow.com/questions/972226/how-to-version-rest-uris - and plenty more... -- Bill Moseley mose...@hank.org
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/