Class: RackReverseProxy::Middleware

Inherits:
Object
  • Object
show all
Includes:
NewRelic::Agent::Instrumentation::ControllerInstrumentation
Defined in:
lib/rack_reverse_proxy/middleware.rb

Overview

Rack middleware for handling reverse proxying

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :preserve_host => true,
  :stripped_headers => nil,
  :x_forwarded_headers => true,
  :matching => :all,
  :replace_response_host => false
}

Instance Method Summary collapse

Constructor Details

#initialize(app = nil, &b) ⇒ Middleware

Returns a new instance of Middleware.



19
20
21
22
23
24
# File 'lib/rack_reverse_proxy/middleware.rb', line 19

def initialize(app = nil, &b)
  @app = app || lambda { |_| [404, rack_version_less_than_three ? [] : {}, []] }
  @rules = []
  @global_options = DEFAULT_OPTIONS
  instance_eval(&b) if block_given?
end

Instance Method Details

#call(env) ⇒ Object



26
27
28
# File 'lib/rack_reverse_proxy/middleware.rb', line 26

def call(env)
  RoundTrip.new(@app, env, @global_options, @rules).call
end