class HoundListSync::Http::Net
Constants
- HEADERS
Public Class Methods
new(logger: nil)
click to toggle source
# File lib/hound_list_sync/http.rb, line 29 def initialize(logger: nil) @logger = logger end
Public Instance Methods
get(url, headers:, basic_auth: [])
click to toggle source
# File lib/hound_list_sync/http.rb, line 33 def get(url, headers:, basic_auth: []) conn = Faraday.new(url: url, headers: HEADERS.merge(headers)) do |faraday| faraday.basic_auth(*basic_auth) if basic_auth.any? faraday.request :retry faraday.response :follow_redirects faraday.response :raise_error if @logger faraday.response :logger, @logger do |logger| logger.filter(/(Authorization: )(.+)/i, '\1[REMOVED]') end end end resp = conn.get Response.new(resp.status, resp.headers, resp.body) end