Class: Pindo::HttpClient
- Inherits:
-
Object
- Object
- Pindo::HttpClient
- Defined in:
- lib/pindo/client/httpclient.rb
Instance Attribute Summary collapse
-
#baseurl ⇒ Object
Returns the value of attribute baseurl.
-
#request_config ⇒ Object
Returns the value of attribute request_config.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Instance Attribute Details
#baseurl ⇒ Object
Returns the value of attribute baseurl.
82 83 84 |
# File 'lib/pindo/client/httpclient.rb', line 82 def baseurl @baseurl end |
#request_config ⇒ Object
Returns the value of attribute request_config.
83 84 85 |
# File 'lib/pindo/client/httpclient.rb', line 83 def request_config @request_config end |
#token ⇒ Object
Returns the value of attribute token.
81 82 83 |
# File 'lib/pindo/client/httpclient.rb', line 81 def token @token end |
Class Method Details
.create_instance ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/pindo/client/httpclient.rb', line 112 def self.create_instance() con = Faraday.new do |config| # 使用自定义重试中间件 config.use SimpleRetryMiddleware, max: 3, interval: 0.5, backoff_factor: 2 # 使用 Typhoeus 适配器 config.adapter :typhoeus end con end |
.create_instance_with_proxy ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/pindo/client/httpclient.rb', line 85 def self.create_instance_with_proxy() # puts body_params.to_json = { uri: ENV['http_proxy'] || ENV['https_proxy'], user: ENV['HTTP_PROXY_USER'], password: ENV['HTTP_PROXY_PASSWORD'] } = { max: 3, interval: 0.5, backoff_factor: 2, interval_randomness: 0.5 } con = Faraday.new do |config| # 使用自定义重试中间件 config.use SimpleRetryMiddleware, # 使用 Typhoeus 适配器(支持代理和连接池) config.adapter :typhoeus config.proxy = .compact if [:uri] end con end |