In preparation to moving forward with the new DSL, the
Accept/file extension matching has been changed in HEAD.
This may be necessary to be changed in the future, but
I have a slim hope of being able to support both dumb
web browsers and rich clients in the same callpath, thus
expressed:
The basic idea is that a file extension, if present, will
override anything in Accept with its own MIME type. The
absence of an extension is indicated with Mime::Undefined,
allowing e.g. matching /foo/bar to the text/html repr.
Code is typically better than some number of words, so
please see the Accept test file:
http://github.com/waves/edge/blob/fc0b801e5c61cbf0efcba08d0604920d75e45a2f/test/match/accept.rb
The scheme is slightly more cumbersome than the current,
but richer. It will be abstracted away under the new DSL.
Regards,
Eero <rue>
--
Magic is insufficiently advanced technology.
I re-enabled the Ext matcher as a backup, although in my
view the Accept matcher should be the primary one used in
all contexts, and it can still be used with extensions as
well, its semantics are unchanged. We discussed possibly
moving the combined matching to Requested (or something),
but I have not addressed that here.
Otherwise, I added a bunch of matcher specs and fairly
significantly altered the matcher processing. Please
chime up if there is a problem.
(I use the convention of :matcher, Header as a shorthand.)
Before going any further, I should point out that the issue
is essentially moot: I have no qualms with the :requested
matcher (in particular because the REST DSL will never use
it explicitly, I hope.) I shall explain my reasoning for
originally just modifying :accept instead, though:
Notably, I think the main miscommunication was because we
viewed the :accept matcher slightly differently: it seemed
to me that Dan's view was that :accept should be exactly and
only the contents of the Accept header.
My view, oddly enough, had absolutely nothing to do with a
preceding practice. Aside from my continued belief that the
HTTP spec is broken on this part ("accept" is not a good
term to mean "request", which is what the HTTP logic really
means), my starting point was that doing thing strictly by
(the intention of) the spec is the only option. This means
that, conceptually, the type should be specified only by
Accept and consequently that is how we should determine the
type requested.
There is just the small matter of web browsers.
I disagree on the point of resource identifiers; aside from
the obvious part that they somehow identify a resource, it
is another poorly defined part of the REST architecture.
Because the HTTP spec says nothing about file extensions,
and because it is somewhat awkward to consider /foo/bar.txt
and /foo/bar.html to be different resources, and because it
is a fairly well-established convention *elsewhere* to use
extensions as type indicators, to me extensions would be
the natural __workaround__ for the inability of browsers to
actually set the Accepts correctly (although this may be
changing in HTML5.)
So this takes us to the argument Dan was sort of going at
the end, and which was the original problem I was solving.
I do not think we have a good solution, still, but here is
one proposal:
1. Using :requested means you do not care how the type is
resolved, just that all clients can indicate it and
that you get the information.
2. In your responses, the links can be either given with
info suitable to use in Accept, or simply appended the
appropriate extension to. (The latter generally only
being the case when you are returning a HTML variant.)
3. There is no need to change code when/if Accept becomes
dominant.
This probably fits most use cases. But is it the best way?
What do the alternatives (either for :requested generally
or for using file extensions in particular) look like?