Class: Railbox::HttpClient::Faraday
- Inherits:
-
Object
- Object
- Railbox::HttpClient::Faraday
- Defined in:
- lib/railbox/http_client/faraday.rb
Class Method Summary collapse
Class Method Details
.logger_options ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/railbox/http_client/faraday.rb', line 22 def { headers: {request: true, response: true}, bodies: {request: true, response: true}, errors: true, log_level: :info } end |
.request(method, url, query = {}, body = {}, headers = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/railbox/http_client/faraday.rb', line 5 def request(method, url, query = {}, body = {}, headers = {}) connection = ::Faraday.new do |config| config.adapter :httpclient config.request :json config.response :json, parser_options: {symbol_keys: true} config.response :raise_error config.response :logger, Rails.logger, end connection.send(method, url) do |req| req.params = query if query.present? req.headers = headers if headers.present? req.body = body if body.present? && method != :get end end |