Class: Invoker::Power::UrlRewriter

Inherits:
Object
  • Object
show all
Defined in:
lib/invoker/power/url_rewriter.rb

Instance Method Summary collapse

Instance Method Details

#extract_host_from_domain(complete_path) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/invoker/power/url_rewriter.rb', line 16

def extract_host_from_domain(complete_path)
  matching_strings = []
  tld_match_regex.map do |regexp|
    if (match_result = complete_path.match(regexp))
      matching_strings << match_result[1]
    end
  end
  matching_strings.uniq
end

#select_backend_config(complete_path) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/invoker/power/url_rewriter.rb', line 4

def select_backend_config(complete_path)
  possible_matches = extract_host_from_domain(complete_path)
  exact_match = nil
  possible_matches.each do |match|
    if match
      exact_match = dns_check(process_name: match)
      break if exact_match.port
    end
  end
  exact_match
end