Class: WebShield::Config
- Inherits:
-
Object
- Object
- WebShield::Config
- Defined in:
- lib/web_shield/config.rb
Instance Attribute Summary collapse
-
#blocked_response ⇒ Object
Returns the value of attribute blocked_response.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#shields ⇒ Object
readonly
Returns the value of attribute shields.
-
#store ⇒ Object
Returns the value of attribute store.
-
#user_parser ⇒ Object
Returns the value of attribute user_parser.
Instance Method Summary collapse
- #build_shield(path_matcher, options, shield_class = ThrottleShield) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 |
# File 'lib/web_shield/config.rb', line 8 def initialize @shields = [] @shield_counter = 0 @user_parser = Proc.new {|req| req.ip } @blocked_response = Proc.new {|req| [429, {}, ['Too Many Requests']] } @logger = Logger.new($stdout) end |
Instance Attribute Details
#blocked_response ⇒ Object
Returns the value of attribute blocked_response.
5 6 7 |
# File 'lib/web_shield/config.rb', line 5 def blocked_response @blocked_response end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/web_shield/config.rb', line 5 def logger @logger end |
#shields ⇒ Object (readonly)
Returns the value of attribute shields.
6 7 8 |
# File 'lib/web_shield/config.rb', line 6 def shields @shields end |
#store ⇒ Object
Returns the value of attribute store.
5 6 7 |
# File 'lib/web_shield/config.rb', line 5 def store @store end |
#user_parser ⇒ Object
Returns the value of attribute user_parser.
5 6 7 |
# File 'lib/web_shield/config.rb', line 5 def user_parser @user_parser end |
Instance Method Details
#build_shield(path_matcher, options, shield_class = ThrottleShield) ⇒ Object
33 34 35 36 |
# File 'lib/web_shield/config.rb', line 33 def build_shield(path_matcher, , shield_class = ThrottleShield) shields << shield_class.new(@shield_counter += 1, path_matcher, , self) logger.info("Build shield #{shields.last.id} #{path_matcher} #{}") end |