Sha256: 88e00241671f13399ad0d45eb5af8b6ea8d0eb1ad5ee0f7c6b0dfc7a4c389da9

Contents?: true

Size: 623 Bytes

Versions: 1

Compression:

Stored size: 623 Bytes

Contents

require "active_record"
require "rails_api_logger/version"
require "rails_api_logger/request_log"
require "rails_api_logger/inbound_request_log"
require "rails_api_logger/outbound_request_log"
require "rails_api_logger/inbound_requests_logger"

module RailsApiLogger
  class Error < StandardError; end

  def self.call(uri, http, request)
    log = OutboundRequestLog.from_request(request)

    http.request(request).tap do |response|
      log.response_code = response.code
      log.response_body = response.body
    end
  rescue => e
    log.response_body = {error: e.message}
    raise
  ensure
    log.save!
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_api_logger-0.1.1 lib/rails_api_logger.rb