Hi everyone,

I'm using restlet to write a Search service..
This service will respond in XML or JSon..

Actually I have a code like that :
== 8< ======================================
public class SearchResource extends ServerResource {

  @Get("xml")
  public Representation doXmlSearch(Variant v) throw ResourceException {
    return new XmlSearchResponseRepresentation(doSearch(getRequest()));
  }

  @Get("json")
  public Representation doJSonSearch(Variant v) throw ResourceException {
    return new JSonSearchResponseRepresentation(doSearch(getRequest()));
  }

}
== 8< ======================================

As you can see, the unique difference is the Representation name. So I wonder 
if it is a way to write only one method that make a "if" on the requested 
variant to create an Xml or JSon representation..

Thanks

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

Reply via email to