Class: HttpEventstore::Api::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/http_eventstore/api/connection.rb

Constant Summary collapse

APP_JSON =
'application/json'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(endpoint) ⇒ Connection

Returns a new instance of Connection.



6
7
8
# File 'lib/http_eventstore/api/connection.rb', line 6

def initialize(endpoint)
  @endpoint = endpoint
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/http_eventstore/api/connection.rb', line 10

def call
  Faraday.new(
      url: endpoint.url,
      headers: {
          accept: APP_JSON,
          content_type: APP_JSON
      }
  ) do |builder|
    builder.adapter Faraday.default_adapter
    builder.response :json, content_type: APP_JSON
    builder.response :mashify
    builder.use ErrorsHandler
  end
end