1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

lighten readme by moving detailed docs to restclient module

This commit is contained in:
Adam Wiggins 2008-08-01 11:39:24 -07:00
parent cad9caaf6f
commit 4218b68370
2 changed files with 30 additions and 7 deletions

10
README
View file

@ -7,14 +7,10 @@ of specifying actions: get, put, post, delete.
require 'rest_client'
xml = RestClient.get 'http://example.com/resource'
jpg = RestClient.get 'http://example.com/resource', :accept => 'image/jpg'
RestClient.get 'http://example.com/resource'
RestClient.get 'https://user:password@example.com/private/resource'
private_resource = RestClient.get 'https://user:password@example.com/private/resource'
RestClient.put 'http://example.com/resource', File.read('my.pdf'), :content_type => 'application/pdf'
RestClient.post 'http://example.com/resource', xml, :content_type => 'application/xml'
RestClient.post 'http://example.com/resource', :param1 => 'one', :nested => { :param2 => 'two' }
RestClient.delete 'http://example.com/resource'

View file

@ -5,6 +5,33 @@ require File.dirname(__FILE__) + '/resource'
require File.dirname(__FILE__) + '/request_errors'
# This module's static methods are the entry point for using the REST client.
#
# # GET
# xml = RestClient.get 'http://example.com/resource'
# jpg = RestClient.get 'http://example.com/resource', :accept => 'image/jpg'
#
# # authentication and SSL
# RestClient.get 'https://user:password@example.com/private/resource'
#
# # POST or PUT with a hash sends parameters as a urlencoded form body
# RestClient.post 'http://example.com/resource', :param1 => 'one'
#
# # nest hash parameters
# RestClient.post 'http://example.com/resource', :nested => { :param1 => 'one' }
#
# # POST and PUT with raw payloads
# RestClient.post 'http://example.com/resource', 'the post body', :content_type => 'text/plain'
# RestClient.post 'http://example.com/resource.xml', xml_doc
# RestClient.put 'http://example.com/resource.pdf', File.read('my.pdf'), :content_type => 'application/pdf'
#
# # DELETE
# RestClient.delete 'http://example.com/resource'
#
# For live tests of RestClient, try using http://rest-test.heroku.com, which echoes back information about the rest call:
#
# >> RestClient.put 'http://rest-test.heroku.com/resource', :foo => 'baz'
# => "PUT http://rest-test.heroku.com/resource with a 7 byte payload, content type application/x-www-form-urlencoded {\"foo\"=>\"baz\"}"
#
module RestClient
def self.get(url, headers={})
Request.execute(:method => :get,