Hi Matt,

> The next and more important REST and url extension and return format? I am in 
> the quandry of deciding to do my rest API via extension or an 'optional' 
> argument. I have included a snippit of my spring config below...
> 
> i.e.
> 
> 1) myapi/v1/company/1.xml (or rss, json) bla bla bla
> 
> 2) a) myapi/v1/company/1 -> default xml
>      b) myapi/v1/company/1&format=xml
>      c) myapi/v1/company/1/&format=xml
>      
> 2a and 2c works right out of the box so to speak. However 1 and 2b break 
> since they pass in 1.xml and 1&format=xml in the company {id} param. I would 
> like to make my urls at least work for 2b or possibly 1 as well. I was not 
> sure if I had to define some special regex in my routes for each pattern or 
> if there was a global way to do cush filtering/url munging with restlet. Or 
> if I had to roll my own. My end goal is to switch the accepted varient type 
> based on either uri extension or optional format=XXX but get some strange 
> behaviour in the routing itself.

The protocoll HTTP has content negotiation included. Normally you could use it 
via the appropriate http headers. Restlet supports this also via url 
parameters, so you are not required to implement it yourself. You could use the 
TunnelService of the application for it. See the methods on 
Application.getTunnelService.set*() and their javadoc. So it's easy to realize 
you proposal 2b.
The TunnelService supports also the content negotiation by file extension, as 
you proposed in 1). So, it's all in Restlet, just use it. Use 
Application.getTunnelService().setExtensionTunnel(true).

http://www.restlet.org/documentation/1.1/tutorial#part12 shows, how to evaluate 
the content negotiation in the server code.

best regards
   Stephan
_______________________________________________________________________
Sensationsangebot verlängert: WEB.DE FreeDSL - Telefonanschluss + DSL
für nur 16,37 Euro/mtl.!* http://dsl.web.de/?ac=OM.AD.AD008K15039B7069a

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=990476

Reply via email to