Class: Resty::Transport
- Inherits:
-
Object
- Object
- Resty::Transport
- Defined in:
- lib/resty/transport.rb
Class Attribute Summary collapse
-
.default_href_params ⇒ Object
Returns the value of attribute default_href_params.
Class Method Summary collapse
Class Attribute Details
.default_href_params ⇒ Object
Returns the value of attribute default_href_params.
4 5 6 |
# File 'lib/resty/transport.rb', line 4 def default_href_params @default_href_params end |
Class Method Details
.request_json(href, method = 'GET', body = nil, content_type = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/resty/transport.rb', line 7 def self.request_json(href, method = 'GET', body = nil, content_type = nil) headers = content_type ? { :content_type => content_type } : nil payload = body || '' response = RestClient::Request.execute( :url => add_default_params(href), :method => method, :payload => payload, :headers => headers ) if !(response.nil? || response =~ /\A\s*\Z/) JSON.parse(response) elsif !response.nil? && response.headers[:location] { ':href' => response.headers[:location] } else nil end end |