Class: Tire::HTTP::Client::RestClient

Inherits:
Object
  • Object
show all
Defined in:
lib/tire/http/client.rb

Constant Summary collapse

ConnectionExceptions =
[::RestClient::ServerBrokeConnection, ::RestClient::RequestTimeout]

Class Method Summary collapse

Class Method Details

.delete(url) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/tire/http/client.rb', line 37

def self.delete(url)
  perform ::RestClient.delete(url)
rescue *ConnectionExceptions
  raise
rescue ::RestClient::Exception => e
  Response.new e.http_body, e.http_code
end

.get(url, data = nil) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/tire/http/client.rb', line 13

def self.get(url, data=nil)
  perform ::RestClient::Request.new(:method => :get, :url => url, :payload => data).execute
rescue *ConnectionExceptions
  raise
rescue ::RestClient::Exception => e
  Response.new e.http_body, e.http_code
end

.head(url) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/tire/http/client.rb', line 45

def self.head(url)
  perform ::RestClient.head(url)
rescue *ConnectionExceptions
  raise
rescue ::RestClient::Exception => e
  Response.new e.http_body, e.http_code
end

.post(url, data) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/tire/http/client.rb', line 21

def self.post(url, data)
  perform ::RestClient.post(url, data)
rescue *ConnectionExceptions
  raise
rescue ::RestClient::Exception => e
  Response.new e.http_body, e.http_code
end

.put(url, data) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/tire/http/client.rb', line 29

def self.put(url, data)
  perform ::RestClient.put(url, data)
rescue *ConnectionExceptions
  raise
rescue ::RestClient::Exception => e
  Response.new e.http_body, e.http_code
end