I'd probably myself want some plack middleware that would convert

/api/v1/account/<id>/widget/<id>


to 


/account/<id>/widget/<id>    with accept type application/mycompany.v1+json

But you could probably support changing the URL path pretty easily with either 
setting the controller namespace to have v1 in it, or adding a root tot he 
change that specifies the new extra path part.

I understand the development word seems to prefer making version part of the 
path.  depending on your logic and the type of changes introduced it may or may 
not be easier to take one approach or the other.

john


On Tuesday, October 15, 2013 1:01 PM, Bill Moseley <mose...@hank.org> wrote:

Over in this thread was a discussion on API versioning and implementing via 
Accept: headers vs. adding a version in the URL.   Looks like using a version 
in the URL is winning.

We have existing chained actions that might look like this:

/account/<id>/widget/<id>

If want to migrate to a new version scheme in the URL like this:

/api/v1/account/<id>/widget/<id>

This would be the same action chain as the first path -- and both would work at 
the same time.

Is there any way to support both actions via Chained dispatching?   Or will I 
need a role that looks for that pattern and strips it of the request during 
prepare_action?

I've done something similar in the past where I added a language tag at the 
start of every path:

/en_us/some/path/1234

I strip that off and then update $c->req->path for dispatching.




Again, I'm in the Accept: header camp for versioning, but I'm finding more and 
more discussion on using URLs.    There's an e-book that seems to be cited 
often. I'd be interested in other's view on that book -- it seems written from 
a practical Rails programmer point of view instead of a REST purist view.   
There's a lot in that e-book I don't really agree with (plural nouns?), but the 
practical usage seems to be winning out.  Hope it's not a mistake in the long 
run.


-- 
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/

_______________________________________________
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/

Reply via email to