more on multiple media types

2007-12-14 @ 10:26#

i've been spending time this week improving supoprt for multiple media types in exyus. first, i added support for media type collections for the resource class itself. this list is then queried at runtime when a client makes a request and the client Accept header is honored (or, if necessary rejected with 415). all is cool.

then i realized that PUT/POST will need support for media types as well. so i mapped out adding a second media type list for PUT/POST. currently, if no secondary list is supplied, exyus assumes the MediaTypes collection for the resource is also valid for PUT/POST. no problem.

so i have support for media types for GET/HEAD and PUT/POST. nice. but how will clients know about all this? i checked out Fieldings dissertation (the final source for most all things REST-y) and find this:

HTTP/1.1 added the notion of reactive (agent-driven) negotiation. In this case, when a user agent requests a negotiated resource, the server responds with a list of the available representations. The user agent can then choose which one is best according to its own capabilities and purpose. The information about the available representations may be supplied via a separate representation (e.g., a 300 response), inside the response data (e.g., conditional HTML), or as a supplement to the "most likely" response. The latter works best for the Web because an additional interaction only becomes necessary if the user agent decides one of the other variants would be better. Reactive negotiation is simply an automated reflection of the normal browser model, which means it can take full advantage of all the performance benefits of REST. Content Negotiation

so, it would seem some kind of pattern for passing additional hyperlinks in the "most likely" response is a possible solution. but i'm not seeing this anywhere. i see lots of other possible solutions:

but not much consensus.