Sha256: 6be52daa072a57f77fed8907439ccd510f319a644176ae7601763379174bd862
Contents?: true
Size: 1015 Bytes
Versions: 1
Compression:
Stored size: 1015 Bytes
Contents
require 'faraday' module Marvel class Api module HTTPService class << self attr_accessor :faraday_middleware, :http_options private def faraday_options(options) valid_options = %i[ request proxy ssl builder url parallel_manager params headers builder_class ] Hash[options.select { |key, _| valid_options.include?(key) }] end end self.http_options ||= {} DEFAULT_MIDDLEWARE = proc do |builder| builder.adapter Faraday.default_adapter end def self.make_request(request) connection = Faraday.new( request.server, faraday_options(request.options), &(faraday_middleware || DEFAULT_MIDDLEWARE) ) response = connection.send(request.verb, request.path, request.args) Marvel::Api::Response.new( status: response.status.to_i, headers: response.headers, body: response.body ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
marvel-api-0.1.0 | lib/marvel/api/http_service.rb |