Sha256: 26a62f9e52c79b9439982dc4c1fa0bda2648698f4391443fe4e7832198ef0bdd
Contents?: true
Size: 801 Bytes
Versions: 1
Compression:
Stored size: 801 Bytes
Contents
module InboundRequestsLogger extend ActiveSupport::Concern private def log_inbound_request @inbound_request_log = InboundRequestLog.from_request(request) yield @inbound_request_log.update(response_body: JSON.parse(response.body), response_code: response.code) end def request_with_state_change? request.post? || request.put? || request.patch? || request.delete? end def request_without_body? request.get? || request.head? || request.options? || request.delete? end def attach_inbound_request_loggable(loggable) @inbound_request_log.loggable = loggable if loggable&.persisted? end end ActiveSupport.on_load(:action_controller) do include InboundRequestsLogger end ActiveSupport.on_load(:action_controller_api) do include InboundRequestsLogger end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_api_logger-0.1.1 | lib/rails_api_logger/inbound_requests_logger.rb |