Class: ApiLogger::Configuration
- Inherits:
-
Object
- Object
- ApiLogger::Configuration
- Defined in:
- lib/api_logger/configuration.rb
Instance Attribute Summary collapse
-
#allowed_hosts ⇒ Object
Returns the value of attribute allowed_hosts.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#exclude_hosts ⇒ Object
Returns the value of attribute exclude_hosts.
-
#exclude_routes ⇒ Object
Returns the value of attribute exclude_routes.
-
#table_name ⇒ Object
Returns the value of attribute table_name.
-
#use_middleware ⇒ Object
Returns the value of attribute use_middleware.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #should_log_route?(path, host = nil) ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 8 9 10 11 12 13 |
# File 'lib/api_logger/configuration.rb', line 5 def initialize @table_name = 'api_logs' @enabled = true @use_middleware = true @allowed_hosts = ['services.mfcentral.com', 'uatservices.mfcentral.com'] # backwards compatibility, to be removed in next release. @exclude_hosts = [] @exclude_routes = [] end |
Instance Attribute Details
#allowed_hosts ⇒ Object
Returns the value of attribute allowed_hosts.
3 4 5 |
# File 'lib/api_logger/configuration.rb', line 3 def allowed_hosts @allowed_hosts end |
#enabled ⇒ Object
Returns the value of attribute enabled.
3 4 5 |
# File 'lib/api_logger/configuration.rb', line 3 def enabled @enabled end |
#exclude_hosts ⇒ Object
Returns the value of attribute exclude_hosts.
3 4 5 |
# File 'lib/api_logger/configuration.rb', line 3 def exclude_hosts @exclude_hosts end |
#exclude_routes ⇒ Object
Returns the value of attribute exclude_routes.
3 4 5 |
# File 'lib/api_logger/configuration.rb', line 3 def exclude_routes @exclude_routes end |
#table_name ⇒ Object
Returns the value of attribute table_name.
3 4 5 |
# File 'lib/api_logger/configuration.rb', line 3 def table_name @table_name end |
#use_middleware ⇒ Object
Returns the value of attribute use_middleware.
3 4 5 |
# File 'lib/api_logger/configuration.rb', line 3 def use_middleware @use_middleware end |
Instance Method Details
#should_log_route?(path, host = nil) ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'lib/api_logger/configuration.rb', line 15 def should_log_route?(path, host = nil) return false unless enabled && use_middleware return false unless host # Only log if host is in allowed list allowed_hosts.include?(host) end |