Class: Rack::ReverseProxyMatcher
- Inherits:
-
Object
- Object
- Rack::ReverseProxyMatcher
- Defined in:
- lib/rack/reverse_proxy.rb
Instance Attribute Summary collapse
-
#matching ⇒ Object
readonly
Returns the value of attribute matching.
-
#matching_regexp ⇒ Object
readonly
Returns the value of attribute matching_regexp.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #get_uri(path, env) ⇒ Object
-
#initialize(matching, url, options) ⇒ ReverseProxyMatcher
constructor
A new instance of ReverseProxyMatcher.
- #match?(path) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(matching, url, options) ⇒ ReverseProxyMatcher
Returns a new instance of ReverseProxyMatcher.
144 145 146 147 148 149 |
# File 'lib/rack/reverse_proxy.rb', line 144 def initialize(matching,url,) @matching=matching @url=url @options= @matching_regexp= matching.kind_of?(Regexp) ? matching : /^#{matching.to_s}/ end |
Instance Attribute Details
#matching ⇒ Object (readonly)
Returns the value of attribute matching.
151 152 153 |
# File 'lib/rack/reverse_proxy.rb', line 151 def matching @matching end |
#matching_regexp ⇒ Object (readonly)
Returns the value of attribute matching_regexp.
151 152 153 |
# File 'lib/rack/reverse_proxy.rb', line 151 def matching_regexp @matching_regexp end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
151 152 153 |
# File 'lib/rack/reverse_proxy.rb', line 151 def @options end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
151 152 153 |
# File 'lib/rack/reverse_proxy.rb', line 151 def url @url end |
Instance Method Details
#get_uri(path, env) ⇒ Object
157 158 159 160 161 162 163 164 165 |
# File 'lib/rack/reverse_proxy.rb', line 157 def get_uri(path,env) _url=(url.respond_to?(:call) ? url.call(env) : url.clone) if _url =~/\$\d/ match_path(path).to_a.each_with_index { |m, i| _url.gsub!("$#{i.to_s}", m) } URI(_url) else URI.join(_url, path) end end |
#match?(path) ⇒ Boolean
153 154 155 |
# File 'lib/rack/reverse_proxy.rb', line 153 def match?(path) match_path(path) ? true : false end |
#to_s ⇒ Object
166 167 168 |
# File 'lib/rack/reverse_proxy.rb', line 166 def to_s %Q("#{matching.to_s}" => "#{url}") end |