class Shift::Api::Core::Middleware::CustomHeaders
Faraday middleware to add extra headers to the request
Attributes
app[RW]
headers[RW]
Public Class Methods
new(app, headers:)
click to toggle source
# File lib/shift/api/core/middleware/custom_headers.rb, line 9 def initialize(app, headers:) self.app = app self.headers = headers end
Public Instance Methods
call(env)
click to toggle source
Adds the custom headers to the passed in environment @param [Faraday::Env] env The environment from faraday
# File lib/shift/api/core/middleware/custom_headers.rb, line 16 def call(env) extra_headers = headers extra_headers = headers.call(env) if headers.respond_to?(:call) env.request_headers.merge!(extra_headers) app.call(env) end