Sha256: 3991fa6bf8d1fb7c15abd6e72ee5114bf8565ed6e661aa49bd2d76362616ab14
Contents?: true
Size: 935 Bytes
Versions: 1
Compression:
Stored size: 935 Bytes
Contents
require 'faraday' require 'faraday_middleware' module MercuryParser module Connection # Instantiate a Faraday::Connection # @private private # Returns a Faraday::Connection object # # @return [Faraday::Connection] def connection(options = {}) options = { :url => MercuryParser.api_endpoint }.merge(options) connection = Faraday.new(options) do |c| # encode request params as "www-form-urlencoded" c.use Faraday::Request::UrlEncoded c.use FaradayMiddleware::FollowRedirects, limit: 3 # raise exceptions on 40x, 50x responses c.use Faraday::Response::RaiseError c.response :xml, :content_type => /\bxml$/ c.response :json, :content_type => /\bjson$/ c.adapter Faraday.default_adapter end connection.headers[:user_agent] = MercuryParser.user_agent connection end end # Connection end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mercury_parser-0.0.1 | lib/mercury_parser/connection.rb |