Class: LinkedIn::FaradayMiddleware::FormatRequest

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/linkedin/faraday_middleware/format_request.rb

Constant Summary collapse

HEADER_NAME =
'X-Li-Format'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app = nil, format = :json) ⇒ FormatRequest

Returns a new instance of FormatRequest.



6
7
8
9
# File 'lib/linkedin/faraday_middleware/format_request.rb', line 6

def initialize(app = nil, format = :json)
  super app
  @format = format
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
# File 'lib/linkedin/faraday_middleware/format_request.rb', line 11

def call(env)
  env[:request_headers].reverse_merge! HEADER_NAME => @format.to_s unless @format.blank?
  @app.call env
end