Class: Rack::ReverseProxyRule

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/reverse_proxy_rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule) ⇒ ReverseProxyRule

Returns a new instance of ReverseProxyRule.



4
5
6
7
8
9
10
# File 'lib/rack/reverse_proxy_rule.rb', line 4

def initialize rule
  if rule.kind_of?(Proc) || rule.respond_to?(:call)
    @rule = rule
  else
    raise "Invalid Rule for reverse_proxy"
  end
end

Instance Attribute Details

#ruleObject (readonly)

Returns the value of attribute rule.



12
13
14
# File 'lib/rack/reverse_proxy_rule.rb', line 12

def rule
  @rule
end

#urlObject (readonly)

Returns the value of attribute url.



12
13
14
# File 'lib/rack/reverse_proxy_rule.rb', line 12

def url
  @url
end

Instance Method Details

#get_uriObject



18
19
20
21
# File 'lib/rack/reverse_proxy_rule.rb', line 18

def get_uri
  return nil if @url.nil?
  URI.parse(@url)
end

#match?(env) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rack/reverse_proxy_rule.rb', line 14

def match? env
  @url = @rule.call env
end