Class: Service::Proxy::ServiceConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/service/proxy/service_config.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ ServiceConfig

Returns a new instance of ServiceConfig.



4
5
6
7
# File 'lib/service/proxy/service_config.rb', line 4

def initialize(name, options)
  @name = name
  @options = options
end

Instance Method Details

#backendObject



9
10
11
# File 'lib/service/proxy/service_config.rb', line 9

def backend
  @backend ||= URI(@options.fetch(:backend, ''))
end

#backend_path_for(original_path) ⇒ Object



13
14
15
16
# File 'lib/service/proxy/service_config.rb', line 13

def backend_path_for(original_path)
  original_path.delete_prefix!(path)
  [backend.path, original_path].compact.join('/').gsub(/\/+/, '/')
end

#pathObject



18
19
20
# File 'lib/service/proxy/service_config.rb', line 18

def path
  @path ||= @options.fetch(:path)
end

#path_regexpObject



22
23
24
# File 'lib/service/proxy/service_config.rb', line 22

def path_regexp
  @path_regexp ||= Regexp.new("^#{Regexp.escape(path)}")
end

#read_timeoutObject



34
35
36
# File 'lib/service/proxy/service_config.rb', line 34

def read_timeout
  @options.fetch(:read_timeout, nil)
end

#send_cookies?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/service/proxy/service_config.rb', line 26

def send_cookies?
  @options.fetch(:forward_cookies, true)
end

#verify_ssl?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/service/proxy/service_config.rb', line 30

def verify_ssl?
  @options.fetch(:verify_ssl, true)
end