class Conjur::WebServer::APIProxy
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/conjur/webserver/api_proxy.rb, line 31 def initialize super nil end
Public Instance Methods
call(env)
click to toggle source
# File lib/conjur/webserver/api_proxy.rb, line 35 def call env request = Request.new(env) request.http_request['Authorization'] = authorization_header response = Rack::StreamingProxy::Session.new(request).start rewrite_response(env, response.status, response.headers, response) end
rewrite_response(*args)
click to toggle source
# File lib/conjur/webserver/api_proxy.rb, line 42 def rewrite_response(*args) env, status, headers, body = args source_request = Rack::Request.new(env) headers = Hash[*headers.flat_map { |k, v| [capitalize_header(k), v] }] headers.delete 'Transfer-Encoding' # let Puma handle chunking # Rewrite location if location = headers["Location"] headers["Location"] = location.gsub(Conjur.configuration.service_url, "http://#{source_request.host}:#{source_request.port}") end [ status, headers, body ] end
Protected Instance Methods
perform_request(env)
click to toggle source
Calls superclass method
# File lib/conjur/webserver/api_proxy.rb, line 67 def perform_request(env) triplet = super(env) [ env ] + triplet end
Private Instance Methods
capitalize_header(hdr)
click to toggle source
# File lib/conjur/webserver/api_proxy.rb, line 74 def capitalize_header hdr hdr.split('-').map(&:capitalize).join('-') end