Class: Proxy::Dynflow::Callback::Core

Inherits:
HttpRequest::ForemanRequest
  • Object
show all
Defined in:
lib/smart_proxy_dynflow/callback.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.relay(request, from, to) ⇒ Object



25
26
27
# File 'lib/smart_proxy_dynflow/callback.rb', line 25

def self.relay(request, from, to)
  self.new.relay request, from, to
end

Instance Method Details

#relay(request, from, to) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/smart_proxy_dynflow/callback.rb', line 11

def relay(request, from, to)
  path = request.path.gsub(from, to)
  Proxy::LogBuffer::Decorator.instance.debug "Proxy request from #{request.host_with_port}#{request.path} to #{uri.to_s}#{path}"
  req = case request.env['REQUEST_METHOD']
          when 'GET'
            request_factory.create_get path, request.env['rack.request.query_hash']
          when 'POST'
            request_factory.create_post path, request.body.read
        end
  response = send_request req
  Proxy::LogBuffer::Decorator.instance.debug "Proxy request status #{response.code} - #{response}"
  response
end

#uriObject



7
8
9
# File 'lib/smart_proxy_dynflow/callback.rb', line 7

def uri
  @uri ||= URI.parse Proxy::Dynflow::Plugin.settings.core_url
end