class SiteHub::Middleware::ReverseProxy
Attributes
path_directives[R]
Public Class Methods
new(app, directives)
click to toggle source
# File lib/sitehub/middleware/reverse_proxy.rb, line 13 def initialize(app, directives) @app = app @path_directives = LocationRewriters.new(directives) end
Public Instance Methods
call(env)
click to toggle source
# File lib/sitehub/middleware/reverse_proxy.rb, line 18 def call(env) status, headers, body = @app.call(env).to_a mapping = env[REQUEST].mapping headers[LOCATION_HEADER] = location(headers, mapping.source_url) if headers[LOCATION_HEADER] rewrite_cookies(headers, substitute_domain: mapping.host) if headers[SET_COOKIE] [status, HttpHeaders.new(headers), body] end
Private Instance Methods
location(headers, source_url)
click to toggle source
# File lib/sitehub/middleware/reverse_proxy.rb, line 31 def location(headers, source_url) location_header = headers[LOCATION_HEADER] path_directives.find(location_header).apply(location_header, source_url) end