From 3ffdbb09b0a36ee8780698153b5a112480270681 Mon Sep 17 00:00:00 2001 From: Michal Cichra Date: Wed, 21 Feb 2018 19:10:30 +0100 Subject: [PATCH] [fetch] detect when running on openshift and use services instead of routes --- .../three_scale/api/instrumented_http_client.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/adapters/three_scale/api/instrumented_http_client.rb b/app/adapters/three_scale/api/instrumented_http_client.rb index c9c335b4..5174b0d1 100644 --- a/app/adapters/three_scale/api/instrumented_http_client.rb +++ b/app/adapters/three_scale/api/instrumented_http_client.rb @@ -5,6 +5,20 @@ # Custom HTTP Client for 3scale API client with added instrumentation., class ThreeScale::API::InstrumentedHttpClient < ThreeScale::API::HttpClient + def initialize(**) + super + + if (system_provider_port = ENV['SYSTEM_PROVIDER_PORT'].presence) + proxy = URI(system_provider_port).freeze + + @http = Net::HTTP.new(proxy.host, proxy.port) + @http.set_debug_output($stdout) if debug? + + @headers = headers.merge('X-Forwarded-Host' => admin_domain, + 'X-Forwarded-Proto' => endpoint.scheme) + end + end + def get(path, params: nil) req = build_request(Net::HTTP::Get, path, params) parse request(req, params: params)