Saturday, March 15, 2008

rest-client




rest-client is a simple API for accessing REST resources with Ruby. Looks really nice and simple.


require 'rest_client'

xml = RestClient.get 'http://some/resource'
jpg = RestClient.get 'http://some/resource', :accept => 'image/jpg'

RestClient.put 'http://some/resource', File.read('my.pdf'), :content_type => 'application/pdf'

RestClient.post 'http://some/resource', xml, :content_type => 'application/xml'

RestClient.delete 'http://some/resource'