Class: Common::Client::Middleware::Logging
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Common::Client::Middleware::Logging
- Defined in:
- lib/common/client/middleware/logging.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, type_key) ⇒ Logging
constructor
A new instance of Logging.
Constructor Details
#initialize(app, type_key) ⇒ Logging
Returns a new instance of Logging.
7 8 9 10 |
# File 'lib/common/client/middleware/logging.rb', line 7 def initialize(app, type_key) super(app) @type_key = type_key end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/common/client/middleware/logging.rb', line 12 def call(env) request_body = Base64.encode64(env.body) if env.body @app.call(env).on_complete do |response_env| PersonalInformationLog.create( error_class: @type_key, # TODO: error_class is probably worth renaming data: { method: env.method, url: env.url.to_s, request_body:, response_body: Base64.encode64(response_env.body) } ) end end |