+1. This seems clean and intuitive to me.
Stefan
--
Stefan Tilkov, http://www.innoq.com/blog/st/
On Mar 10, 2008, at 5:05 PM, Marc Hadley wrote:
> Proposal take 3 (removed the complex per-resource approach to allow
> simple URI preprocessing):
>
> - We only offer automatic support for content types and language,
> nothing for charset or encoding negotiation.
>
> - The feature is controlled by ApplicationConfig.getMediaTypesMap
> (Map<String, MediaType) and ApplicationConfig.getLanguageMap
> (Map<String, String). If both maps are empty (the default) then the
> feature is disabled.
>
> - When the feature is enabled:
>
> * A request URI is pre-processed to remove extensions that match a
> key in the media types or language maps. The corresponding value of
> a matching key is used to override the accept or accept-language
> header.
>
> * If a URI template ends in a variable then the variable value is
> injected without the matching extensions.
>
> - Existing UriInfo methods are not affected, all extensions in the
> URI are included in the path returned by any of the methods. For
> convenience we add:
>
> * UriInfo.getPathExtension() that returns the extensions as a String
> or null if there isn't one,
> * UriInfo.getPlatonicRequestUriBuilder which returns a URI builder
> for the request minus the extensions
> * UriBuilder.extension(String) that adds the supplied extension to
> the current final path segment.
>
> An example:
>
> mediaTypeMap = {"xml"=>"application/xml", "json"=>"application/json"}
> languageMap = {"en"=>"en", "fr"=>"fr"}
>
> @Path("widgets/{id}")
> public class WidgetResource {
> @GET
> String get(@PathParam("id") String id) {
> }
> }
>
> GET /widgets/1 => id=1, accept and accept-language are unaffected
> GET /widgets/1.xml => id=1, accept=application/xml, accept-language
> is unaffected
> GET /widgets/1.json => id=1, accept: application/json, accept-
> language is unaffected
> GET /widgets/1.xml.en => id=1, accept: application/xml, accept-
> language: en
> GET /widgets/1.foo => id=1.foo, accept and accept-language are
> unaffected
> GET /widgets/1.foo.xml => id=1.foo, accept=application/xml, accept-
> language is unaffected
> GET /widgets/1.xml.foo => id=1.foo, accept=application/xml, accept-
> language is unaffected
>
> Thoughts, comments ?
> Marc.
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>
>