Class: Tire::HTTP::Client::RestClient
- Inherits:
-
Object
- Object
- Tire::HTTP::Client::RestClient
- Defined in:
- lib/tire/http/client.rb
Constant Summary collapse
- ConnectionExceptions =
[::RestClient::ServerBrokeConnection, ::RestClient::RequestTimeout]
Class Method Summary collapse
- .__host_unreachable_exceptions ⇒ Object
- .delete(url) ⇒ Object
- .get(url, data = nil) ⇒ Object
- .head(url) ⇒ Object
- .post(url, data) ⇒ Object
- .put(url, data) ⇒ Object
Class Method Details
.__host_unreachable_exceptions ⇒ Object
50 51 52 |
# File 'lib/tire/http/client.rb', line 50 def self.__host_unreachable_exceptions [Errno::ECONNREFUSED, Errno::ETIMEDOUT, ::RestClient::ServerBrokeConnection, ::RestClient::RequestTimeout, SocketError] end |
.delete(url) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/tire/http/client.rb', line 34 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
10 11 12 13 14 15 16 |
# File 'lib/tire/http/client.rb', line 10 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
42 43 44 45 46 47 48 |
# File 'lib/tire/http/client.rb', line 42 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
18 19 20 21 22 23 24 |
# File 'lib/tire/http/client.rb', line 18 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
26 27 28 29 30 31 32 |
# File 'lib/tire/http/client.rb', line 26 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 |