Sha256: ea589f4303edd35b44e6079862183892a39cc27bf6177888778d34d6243060ef

Contents?: true

Size: 865 Bytes

Versions: 2

Compression:

Stored size: 865 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'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loquor-0.6.0 lib/loquor/http_action.rb
loquor-0.5.4 lib/loquor/http_action.rb