Sha256: 3405ddb0f240f4bf6c899523299cef53c485d7202ffbd51fedbb9eb62e6a2a6a
Contents?: true
Size: 976 Bytes
Versions: 15
Compression:
Stored size: 976 Bytes
Contents
# frozen_string_literal: true module PriceHubble module Client module Request # Add some default headers to every request. class DefaultHeaders < Faraday::Middleware # Serve the Faraday middleware API. # # @param env [Hash{Symbol => Mixed}] the request def call(env) env[:request_headers].merge! \ 'User-Agent' => user_agent, 'Accept' => 'application/json' # Set request content type to JSON as fallback env[:request_headers]['Content-Type'] = 'application/json' \ if env[:request_headers]['Content-Type'].blank? @app.call(env) end # Build an useful user agent string to pass. We identify ourself as # +PriceHubbleGem+ with the current gem version. # # @return [String] the user agent string def user_agent "PriceHubbleGem/#{PriceHubble::VERSION}" end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems