class EventStoreClient::HTTP::Connection
Constants
- DEFAULT_HEADERS
Attributes
connection[R]
options[R]
Public Class Methods
new(uri, options = {})
click to toggle source
# File lib/event_store_client/adapters/http/connection.rb, line 22 def initialize(uri, options = {}) @connection = set_connection(uri, options) end
Public Instance Methods
call(method_name, path, body: {}, headers: {})
click to toggle source
# File lib/event_store_client/adapters/http/connection.rb, line 11 def call(method_name, path, body: {}, headers: {}) method = RequestMethod.new(method_name) connection.send(method.to_s, path) do |req| req.headers = req.headers.merge(headers) req.body = body.is_a?(String) ? body : body.to_json req.params['embed'] = 'body' if method == :get end end
Private Instance Methods
set_connection(uri, connection_options)
click to toggle source
# File lib/event_store_client/adapters/http/connection.rb, line 33 def set_connection(uri, connection_options) Faraday.new( { url: uri.to_s, headers: DEFAULT_HEADERS }.merge(connection_options) ) do |conn| conn.basic_auth(config.eventstore_user, config.eventstore_password) conn.adapter Faraday.default_adapter end end