Class: Elastictastic::ThriftAdapter
- Inherits:
-
Faraday::Adapter
- Object
- Faraday::Adapter
- Elastictastic::ThriftAdapter
- Defined in:
- lib/elastictastic/thrift_adapter.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ ThriftAdapter
constructor
A new instance of ThriftAdapter.
Constructor Details
#initialize(app, options = {}) ⇒ ThriftAdapter
Returns a new instance of ThriftAdapter.
12 13 14 15 |
# File 'lib/elastictastic/thrift_adapter.rb', line 12 def initialize(app, = {}) super(app) @options = end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/elastictastic/thrift_adapter.rb', line 17 def call(env) super url = env[:url] req = env[:request] request = Elastictastic::Thrift::RestRequest.new request.method = Elastictastic::Thrift::Method.const_get(env[:method].to_s.upcase) request.body = env[:body] if env[:body] request.uri = url.path parameters = {} request.parameters = url.query_values response = thrift_request(url.host, url.inferred_port, request) save_response(env, response.status, response.body) do |response_headers| if response.headers headers.each_pair do |key, value| response_headers[key] = value end end end @app.call(env) end |