Sha256: 2ae8b6f0fdaf8530177256753ff4e6306fbaa9a392ff421f575edb54ace6f4bf

Contents?: true

Size: 890 Bytes

Versions: 5

Compression:

Stored size: 890 Bytes

Contents

module Loquor
  class HttpAction
    def initialize(url, deps)
      @url = url
      @config = deps[:config]
      @should_cache = deps[:should_cache]
    end

    def signed_request
      @config.logger.info "Signing request."
      ApiAuth.sign!(request, @config.access_id, @config.secret_key)
    end

    def execute
      @config.logger.info "Making HTTP request to: #{full_url}"
      signed_request.execute
    rescue RestClient::ResourceNotFound => e
      @config.logger.error("HTTP 404 when accessing #{full_url}")
      raise
    rescue => e
      @config.logger.error("Exception while executing request: #{e.message} <#{e.class}>")
      raise
    end

    private

    def full_url
      "#{@config.endpoint}#{@url}"
    end
  end
end

require 'loquor/http_actions/get'
require 'loquor/http_actions/post'
require 'loquor/http_actions/put'
require 'loquor/http_actions/delete'

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
loquor-1.10.0 lib/loquor/http_action.rb
loquor-1.9.0 lib/loquor/http_action.rb
loquor-1.8.0 lib/loquor/http_action.rb
loquor-1.7.0 lib/loquor/http_action.rb
loquor-1.6.0 lib/loquor/http_action.rb