[Catalyst] Optional path prefix

Bill Moseley moseley at hank.org
Tue Oct 15 18:00:05 GMT 2013


Over in this thread<http://www.mail-archive.com/catalyst@lists.scsys.co.uk/=
msg14226.html>
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
<http://pages.apigee.com/web-api-design-ebook.html>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
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20131015/a6bd4=
4a2/attachment.htm


More information about the Catalyst mailing list