|
Hi David,
I agree that filename extensions are not the best way to go here, but I see nothing wrong with supporting them in addition to MIME types. As for supporting MIME types, it seems we already have a facility in Restlet via MediaType.valueOf():
@Get(MediaType.APPLICATION_JSON.toString() A tad verbose, but precise and efficient. Also, I've noticed no error if you use an unsupported extension. I think we should have an exception thrown if we try to write something like @Get("fishburger")! Unless a valid MediaType is found, I think it best the ServerResource fail. -Tal
But it's not clear to me why this code should use the "MetadataService" at all. The mapping of file extensions to MediaTypes is one of the web's irritating but hard to avoid dirty shameful secrets. The only time we should stoop so low as to base a MediaType calculation on an extension name is if we have no other choice- in fact, we only have to do this when we DONT have real metadata available!If I am writing a restful web service, and I want to deliver a representation with a mediatype of "image/jpeg", then that's what I should have to put in the @Get annotation- not "jpg" or "jpeg" or "JPG" or any other of the random 3 or 4-letter filename extensions that someone, somewhere, sometime happened to associate (in their anemic filesystem) with that mediatype. (If I sound grumpy it might be because I just spent quite a while with a debugger trying to figure out why my new ServerResource subclass wasn't working, and it turns out it's because I was using "text/html" instead of "htm" or whatever. :-) ) So, I vote for explicit mediatypes. and maybe we also need to be able to specify charsets too? Hmm, maybe that's not useful for content negotiation, not sure. -Dave Fogel ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1528590 |
- Restlet 1.2 M2 released Jerome Louvel
- Re: Restlet 1.2 M2 released Jonathan Hall
- RE: Restlet 1.2 M2 released Jerome Louvel
- Re: Restlet 1.2 M2 released Jonathan Hall
- Re: Restlet 1.2 M2 released Stephan Koops
- Re: Restlet 1.2 M2 released [throw pre... Stephan Koops
- Re: Restlet 1.2 M2 released [throw... Paul Austin
- Re: Restlet 1.2 M2 released [t... Tal Liron
- Re: Restlet 1.2 M2 released [t... David Fogel
- Re: Restlet 1.2 M2 released [t... Tal Liron
- RE: Restlet 1.2 M2 released [t... Jerome Louvel
- Re: Restlet 1.2 M2 released [t... Tal Liron
- RE: Restlet 1.2 M2 released [t... Jerome Louvel
- Re: Restlet 1.2 M2 released [t... Tal Liron
- RE: Restlet 1.2 M2 released [t... Jerome Louvel
- Re: Restlet 1.2 M2 released [t... Tal Liron
- Re: Restlet 1.2 M2 released [t... Rémi Dewitte
- Re: Restlet 1.2 M2 released [t... Tal Liron
- Re: Restlet 1.2 M2 released [t... David Fogel
- RE: Restlet 1.2 M2 released [t... Jerome Louvel

