path prefix is now actually a prefix

This commit is contained in:
Nigel Brookes-Thomas 2020-03-13 12:04:07 +00:00
parent f8ee7b2e91
commit 2cfa847f6f
2 changed files with 5 additions and 2 deletions

View File

@ -37,6 +37,7 @@ class Roda
def proxy def proxy
method = Faraday.method(env['REQUEST_METHOD'].downcase.to_sym) method = Faraday.method(env['REQUEST_METHOD'].downcase.to_sym)
f_response = method.call(_proxy_url) { |req| _proxy_request(req) } f_response = method.call(_proxy_url) { |req| _proxy_request(req) }
pp f_response
_respond(f_response) _respond(f_response)
end end
@ -65,11 +66,13 @@ class Roda
def _proxy_url def _proxy_url
@_proxy_url ||= URI(roda_class.opts[:proxy_to]) @_proxy_url ||= URI(roda_class.opts[:proxy_to])
.then { |uri| uri.path = roda_class.opts[:proxy_path]; uri } .then { |uri| uri.path = roda_class.opts[:proxy_path]; uri } # prefix
.then { |uri| uri.path += env['PATH_INFO'][1..-1]; uri } # path
.then { |uri| uri.query = env['QUERY_STRING']; uri } .then { |uri| uri.query = env['QUERY_STRING']; uri }
end end
def _proxy_headers def _proxy_headers
pp env
env env
.select { |k, _v| k.start_with? 'HTTP_' } .select { |k, _v| k.start_with? 'HTTP_' }
.reject { |k, _v| k == 'HTTP_HOST' } .reject { |k, _v| k == 'HTTP_HOST' }

View File

@ -2,6 +2,6 @@
class Roda class Roda
module Proxy module Proxy
VERSION = '1.0.1' VERSION = '1.0.2'
end end
end end