Class: FlexCommerceApi::JsonApiClientExtension::ForwardedForMiddleware

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/flex_commerce_api/json_api_client_extension/forwarded_for_middleware.rb

Overview

Looks for a lambda defined on the config, calls and assigns it to the outgoing request headers

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/flex_commerce_api/json_api_client_extension/forwarded_for_middleware.rb', line 6

def call(env)
  forwarded_for = FlexCommerceApi.config.forwarded_for

  if forwarded_for.respond_to?(:call)
    env[:request_headers]["X-Forwarded-For"] = forwarded_for.call
  end

  @app.call(env)
end