Class: Rack::DynamicReverseProxy
- Inherits:
-
Object
- Object
- Rack::DynamicReverseProxy
- Defined in:
- lib/rack/dynamic_reverse_proxy.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil, &block) ⇒ DynamicReverseProxy
constructor
A new instance of DynamicReverseProxy.
Constructor Details
#initialize(app = nil, &block) ⇒ DynamicReverseProxy
Returns a new instance of DynamicReverseProxy.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rack/dynamic_reverse_proxy.rb', line 9 def initialize(app = nil, &block) @app = app || lambda {|env| [404, [], []] } @matchers = [] @rules = [] @global_options = { preserve_host: true, x_forwarded_host: true, matching: :all, replace_response_host: false } instance_eval &block if block_given? end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/rack/dynamic_reverse_proxy.rb', line 22 def call(env) rackreq = Rack::Request.new(env) rule = get_rule(rackreq) # return @app.call(env) if matcher.nil? return @app.call(env) if rule.nil? # proxy(env, rackreq, matcher) proxy(env, rackreq, rule) end |