Class: RackReverseProxy::Rule
- Inherits:
-
Object
- Object
- RackReverseProxy::Rule
show all
- Defined in:
- lib/rack_reverse_proxy/rule.rb
Overview
Rule understands which urls need to be proxied
Defined Under Namespace
Classes: Candidate, Matches
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(spec, url = nil, options = {}) ⇒ Rule
Returns a new instance of Rule.
7
8
9
10
11
12
|
# File 'lib/rack_reverse_proxy/rule.rb', line 7
def initialize(spec, url = nil, options = {})
@has_custom_url = url.nil?
@url = url
@options = options
@spec = build_matcher(spec)
end
|
Instance Attribute Details
#options ⇒ Object
FIXME: It needs to be hidden
5
6
7
|
# File 'lib/rack_reverse_proxy/rule.rb', line 5
def options
@options
end
|
Instance Method Details
#get_uri(path, env, *args) ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/rack_reverse_proxy/rule.rb', line 18
def get_uri(path, env, *args)
Candidate.new(
self,
has_custom_url,
path,
env,
matches(path, *args)
).build_uri
end
|
#proxy?(path, *args) ⇒ Boolean
14
15
16
|
# File 'lib/rack_reverse_proxy/rule.rb', line 14
def proxy?(path, *args)
matches(path, *args).any?
end
|
#to_s ⇒ Object
38
39
40
|
# File 'lib/rack_reverse_proxy/rule.rb', line 38
def to_s
%("#{spec}" => "#{url}")
end
|
28
29
30
31
32
33
34
35
36
|
# File 'lib/rack_reverse_proxy/rule.rb', line 28
def transform(path, env, response, request_uri, *args)
Candidate.new(
self,
has_custom_url,
path,
env,
matches(path, *args)
).transform(response, request_uri)
end
|