Class: Modern::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Modern::Request
- Defined in:
- lib/modern/request.rb
Constant Summary collapse
- LOCAL_REQUEST_STORE =
rubocop:disable Style/MutableConstant
{}
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
rubocop:enable Style/MutableConstant.
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(env, logger) ⇒ Request
constructor
A new instance of Request.
- #local_store ⇒ Object
- #request_id ⇒ Object
Constructor Details
#initialize(env, logger) ⇒ Request
Returns a new instance of Request.
14 15 16 17 18 19 20 |
# File 'lib/modern/request.rb', line 14 def initialize(env, logger) super(env) env["HTTP_X_REQUEST_ID"] ||= SecureRandom.uuid @logger = logger.child(request_id: request_id) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
rubocop:enable Style/MutableConstant
12 13 14 |
# File 'lib/modern/request.rb', line 12 def logger @logger end |
Instance Method Details
#cleanup ⇒ Object
30 31 32 |
# File 'lib/modern/request.rb', line 30 def cleanup LOCAL_REQUEST_STORE.delete(request_id) end |
#local_store ⇒ Object
26 27 28 |
# File 'lib/modern/request.rb', line 26 def local_store LOCAL_REQUEST_STORE[request_id] ||= {} end |
#request_id ⇒ Object
22 23 24 |
# File 'lib/modern/request.rb', line 22 def request_id env["HTTP_X_REQUEST_ID"] end |