[Catalyst] How are you handling multiformat URL

John Napiorkowski jjn1056 at yahoo.com
Tue Nov 28 22:53:45 GMT 2006


Hi,

This is more of a best practices type question that's
come up for me again and again and I thought to get
the community's thinking, particularly given the REST
oriented discussion floating around lately.  It's not
specifically about Catalyst although as we further our
best practices discussion I am sure this kind of issue
presents itself.

I often find that the resource of a given URI can have
alternative formats.  For example, I might have a
table of information on an html webpage and I want to
offer two alternative representations, a comma
separated version and an ATOM feed.

According to suggestions for URI best practices, such
as "http://www.w3.org/Provider/Style/URI.html" you
should make your URI for the resource without a file
extension, since you want to make enduring URI's and
who knows if HTML will still be popular in 10 years,
right?

Following this thought I might do something like:

FORMAT   URI
xhtml    myapp.com/table
atom     myapp.com/table?format=atom
cvs      myapp.com/table?format=cvs

Then I can create three different template toolkit
views and decide between them when serializing a URL
based on the format parameter, while making html the
default.  They all come from the same data, just a
different way of seeing it, so they are all
'alternatives' to the one.

However lately I've seen a lot of apps using 'flavour'
style file extensions for this.  Jifty makes extensive
use of this and there is a Flavour plugin for
Catalyst.  So instead of the above you'd do:

FORMAT   URI
xhtml    myapp.com/table (default)
xhtml    myapp.com/table.html
atom     myapp.com/table.atom
cvs      myapp.com/table.cvs

I can see advantages and disadvantages to both
approaches.  For the first method you get the clear
url, but the format parameter might be mistaken for
something other than what it is.  Also there is no
particular standard here for making alternative
representations, someone could use 'format' another
might use 'view', etc whereas the second method has a
clear standard.

So, what are you all doing to handle this?  Has the
'cool urls don't have file extensions' school of
though fallen out of favor?  Has someone found a
better way, or a compelling reason to choose one over
the other?

--John



 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com



More information about the Catalyst mailing list