Mime type filtering.
Requirement: I'm setting up a private service, using restlets under Tomcat. No browser interaction, just a data endpoint for my own use (and to learn a little more about restlets). I want to do a GET, specifying that I can accept application/xml+atom as a mime type. At the server end; Unless this is specified (in the header I think - my knowledge of http isn't very strong) I want the server to reject the GET (error code 406 seems right). Even if no mime type is specified, I will still refuse the GET. Jerome pointed me to extension to MIME type mappings: http://www.restlet.org/documentation/snapshot/api/org/restlet/service/MetadataService.html Is this the best way to do this kind of filtering please? Or use a Tomcat filter? regards -- Dave Pawson XSLT XSL-FO FAQ. Docbook FAQ. http://www.dpawson.co.uk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1112159
Re: Mime type filtering.
Hi Dave! (Shout out from fop-dev back in the day) If you are using the Accept: header in your client ... and using the Restlet Resource model on the server ... just write your responding code in your override of represent(Variant variant). if(variant.getMediaType().equals([the MediaType you speak])){ // do stuff; } else { // return the error status; } I just spotted this example blog that does pretty much what you want: http://www.2048bits.com/2008/06/creating-simple-web-service-with.html On Fri, Feb 6, 2009 at 6:42 AM, Dave Pawson dave.paw...@gmail.com wrote: I want to do a GET, specifying that I can accept application/xml+atom as a mime type. At the server end; Unless this is specified (in the header I think - my knowledge of http isn't very strong) I want the server to reject the GET (error code 406 seems right). Even if no mime type is specified, I will still refuse the GET. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1114729
Re: Mime type filtering.
Hi, On Feb 6, 2009, at 2:55 PM, Rob Heittman wrote: If you are using the Accept: header in your client ... and using the Restlet Resource model on the server ... just write your responding code in your override of represent(Variant variant). if(variant.getMediaType().equals([the MediaType you speak])){ // do stuff; } else { // return the error status; } What Rob's saying will work for sure. You don't even have to handle the 406 yourself -- if you extend Resource and override represent(Variant), Restlet will automatically send the 406 if the represent method returns null. Rhett On Feb 6, 2009, at 2:55 PM, Rob Heittman wrote: Hi Dave! (Shout out from fop-dev back in the day) If you are using the Accept: header in your client ... and using the Restlet Resource model on the server ... just write your responding code in your override of represent(Variant variant). if(variant.getMediaType().equals([the MediaType you speak])){ // do stuff; } else { // return the error status; } I just spotted this example blog that does pretty much what you want: http://www.2048bits.com/2008/06/creating-simple-web-service-with.html On Fri, Feb 6, 2009 at 6:42 AM, Dave Pawson dave.paw...@gmail.com wrote: I want to do a GET, specifying that I can accept application/xml+atom as a mime type. At the server end; Unless this is specified (in the header I think - my knowledge of http isn't very strong) I want the server to reject the GET (error code 406 seems right). Even if no mime type is specified, I will still refuse the GET. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1114757