Module: TN::HTTP
- Defined in:
- lib/tn/http.rb
Defined Under Namespace
Classes: WrapError
Constant Summary collapse
- ClientError =
Class.new(Faraday::ClientError)
Class Method Summary collapse
- .default_connection(*arguments) ⇒ Object
- .default_json_connection(*arguments) ⇒ Object
- .form_connection(*arguments) ⇒ Object
Class Method Details
.default_connection(*arguments) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/tn/http.rb', line 20 def self.default_connection(*arguments) Faraday.new(*arguments) do |conn| conn.use TN::HTTP::WrapError conn.use Faraday::Response::RaiseError yield conn if block_given? conn.adapter Faraday.default_adapter end end |
.default_json_connection(*arguments) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/tn/http.rb', line 36 def self.default_json_connection(*arguments) default_connection(*arguments) do |conn| conn.response :mashify conn.response :json yield conn if block_given? end end |
.form_connection(*arguments) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/tn/http.rb', line 29 def self.form_connection(*arguments) default_connection(*arguments) do |conn| conn.request :url_encoded yield conn if block_given? end end |