class Eventum::Connection

Contains HTTP connection options

Public Instance Methods

execute(method:, path:, config:) click to toggle source

Performs an HTTP request

@param method [Symbol] the HTTP method to perform @param path [String] the path of the URL endpoint to request @param config [Eventum::Configurable] a configuration object

@return [Faraday::Response]

@api private

# File lib/eventum/connection.rb, line 15
def execute(method:, path:, config:)
  conn(config).send(method) do |request|
    request.url path
  end
end

Private Instance Methods

conn(config) click to toggle source

The HTTP connection object

@param config [Eventum::Configurable] a configuration object

@return [Faraday::Connection]

@api private

# File lib/eventum/connection.rb, line 30
def conn(config)
  Faraday.new(url: "#{config.host}:#{config.port}") do |faraday|
    faraday.request :url_encoded
    faraday.adapter config.adapter
    faraday.headers = headers
  end
end
headers() click to toggle source

The default headers for the request

@return [Hash]

@api private

# File lib/eventum/connection.rb, line 43
def headers
  {
    ACCEPT:       "application/json".freeze,
    CONTENT_TYPE: "application/json".freeze
  }
end