Class: Conjur::WebServer::APIProxy
- Inherits:
-
Rack::StreamingProxy::Proxy
- Object
- Rack::StreamingProxy::Proxy
- Conjur::WebServer::APIProxy
- Defined in:
- lib/conjur/webserver/api_proxy.rb
Defined Under Namespace
Classes: Request
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize ⇒ APIProxy
constructor
A new instance of APIProxy.
- #rewrite_response(*args) ⇒ Object
Constructor Details
#initialize ⇒ APIProxy
Returns a new instance of APIProxy.
31 32 33 |
# File 'lib/conjur/webserver/api_proxy.rb', line 31 def initialize super nil end |
Instance Method Details
#call(env) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/conjur/webserver/api_proxy.rb', line 35 def call env request = Request.new(env) request.http_request['Authorization'] = response = Rack::StreamingProxy::Session.new(request).start rewrite_response(env, response.status, response.headers, response) end |
#rewrite_response(*args) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# 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 |