Class: Injest::Middleware
- Inherits:
-
Object
- Object
- Injest::Middleware
- Defined in:
- lib/injest/middleware.rb
Constant Summary collapse
- HEADERS_BLACKLIST =
%w[HTTP_COOKIE].freeze
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#request_type ⇒ Object
readonly
Returns the value of attribute request_type.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #_call(env) ⇒ Object
- #call(env) ⇒ Object
- #init_configuration ⇒ Object
-
#initialize(app, processor: nil) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, processor: nil) ⇒ Middleware
Returns a new instance of Middleware.
7 8 9 10 11 12 13 14 |
# File 'lib/injest/middleware.rb', line 7 def initialize(app, processor: nil) @app = app init_configuration @processor = processor @subject = nil end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/injest/middleware.rb', line 4 def configuration @configuration end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/injest/middleware.rb', line 5 def env @env end |
#request_type ⇒ Object (readonly)
Returns the value of attribute request_type.
5 6 7 |
# File 'lib/injest/middleware.rb', line 5 def request_type @request_type end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
5 6 7 |
# File 'lib/injest/middleware.rb', line 5 def subject @subject end |
Instance Method Details
#_call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/injest/middleware.rb', line 20 def _call(env) @env = env set_request_type return @app.call(env) unless trackable? @request_started_on = Time.now @status, @headers, @response = @app.call(env) @request_ended_on = Time.now set_subject data = build_data data = @processor.call(env, data) unless @processor.nil? append(data) [@status, @headers, @response] end |
#call(env) ⇒ Object
16 17 18 |
# File 'lib/injest/middleware.rb', line 16 def call(env) dup._call(env) end |
#init_configuration ⇒ Object
39 40 41 |
# File 'lib/injest/middleware.rb', line 39 def init_configuration @configuration = Injest::Configuration.instance end |