Class: Rack::PactBroker::SetBaseUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/pact_broker/set_base_url.rb

Constant Summary collapse

X_FORWARDED_PATTERN =
/_X_FORWARDED_/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, base_urls) ⇒ SetBaseUrl

Returns a new instance of SetBaseUrl.



6
7
8
9
# File 'lib/rack/pact_broker/set_base_url.rb', line 6

def initialize app, base_urls
  @app = app
  @base_urls = base_urls
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rack/pact_broker/set_base_url.rb', line 11

def call(env)
  if env["pactbroker.base_url"]
    app.call(env)
  else
    app.call(env.merge("pactbroker.base_url" => select_matching_base_url(env)))
  end
end