Class: AgileProxy::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/agile_proxy/config.rb

Overview

Configuration for the agile proxy

Constant Summary collapse

DEFAULT_WHITELIST =
['127.0.0.1', 'localhost']
RANDOM_AVAILABLE_PORT =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



17
18
19
20
# File 'lib/agile_proxy/config.rb', line 17

def initialize
  @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
  reset
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def cache
  @cache
end

#cache_pathObject

Returns the value of attribute cache_path.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def cache_path
  @cache_path
end

#cache_request_headersObject

Returns the value of attribute cache_request_headers.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def cache_request_headers
  @cache_request_headers
end

#database_config_fileObject

Returns the value of attribute database_config_file.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def database_config_file
  @database_config_file
end

#dynamic_jsonpObject

Returns the value of attribute dynamic_jsonp.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def dynamic_jsonp
  @dynamic_jsonp
end

#dynamic_jsonp_keysObject

Returns the value of attribute dynamic_jsonp_keys.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def dynamic_jsonp_keys
  @dynamic_jsonp_keys
end

#enable_cacheObject

Returns the value of attribute enable_cache.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def enable_cache
  @enable_cache
end

#environmentObject

Returns the value of attribute environment.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def environment
  @environment
end

#ignore_cache_portObject

Returns the value of attribute ignore_cache_port.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def ignore_cache_port
  @ignore_cache_port
end

#ignore_paramsObject

Returns the value of attribute ignore_params.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def ignore_params
  @ignore_params
end

#loggerObject

Returns the value of attribute logger.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def logger
  @logger
end

#non_successful_cache_disabledObject

Returns the value of attribute non_successful_cache_disabled.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def non_successful_cache_disabled
  @non_successful_cache_disabled
end

#non_successful_error_levelObject

Returns the value of attribute non_successful_error_level.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def non_successful_error_level
  @non_successful_error_level
end

#non_whitelisted_requests_disabledObject

Returns the value of attribute non_whitelisted_requests_disabled.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def non_whitelisted_requests_disabled
  @non_whitelisted_requests_disabled
end

#path_blacklistObject

Returns the value of attribute path_blacklist.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def path_blacklist
  @path_blacklist
end

#persist_cacheObject

Returns the value of attribute persist_cache.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def persist_cache
  @persist_cache
end

#proxied_request_connect_timeoutObject

Returns the value of attribute proxied_request_connect_timeout.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def proxied_request_connect_timeout
  @proxied_request_connect_timeout
end

#proxied_request_inactivity_timeoutObject

Returns the value of attribute proxied_request_inactivity_timeout.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def proxied_request_inactivity_timeout
  @proxied_request_inactivity_timeout
end

#proxy_portObject

Returns the value of attribute proxy_port.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def proxy_port
  @proxy_port
end

#server_hostObject

Returns the value of attribute server_host.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def server_host
  @server_host
end

#server_portObject

Returns the value of attribute server_port.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def server_port
  @server_port
end

#webserver_hostObject

Returns the value of attribute webserver_host.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def webserver_host
  @webserver_host
end

#webserver_portObject

Returns the value of attribute webserver_port.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def webserver_port
  @webserver_port
end

#whitelistObject

Returns the value of attribute whitelist.



11
12
13
# File 'lib/agile_proxy/config.rb', line 11

def whitelist
  @whitelist
end

Instance Method Details

#resetObject

Resets the configuration with the defaults



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/agile_proxy/config.rb', line 23

def reset
  @cache = true
  @cache_request_headers = false
  @whitelist = DEFAULT_WHITELIST
  @path_blacklist = []
  @ignore_params = []
  @persist_cache = false
  @dynamic_jsonp = false
  @dynamic_jsonp_keys = ['callback']
  @ignore_cache_port = true
  @non_successful_cache_disabled = false
  @non_successful_error_level = :warn
  @non_whitelisted_requests_disabled = false
  @cache_path = File.join(Dir.tmpdir, 'agile-proxy')
  @proxy_port = RANDOM_AVAILABLE_PORT
  @proxied_request_inactivity_timeout = 10 # defaults from https://github.com/igrigorik/em-http-request/wiki/Redirects-and-Timeouts
  @proxied_request_connect_timeout = 5
  @webserver_port = 3020
  @webserver_host = 'localhost'
  @server_port = 3030
  @server_host = 'localhost'
  @database_config_file = File.join(File.dirname(__FILE__), '..', '..', 'config.yml')
  @environment = ENV['AGILE_PROXY_ENV']
  @enable_cache = false
end