Sha256: efd74bab300e75a7f2956372041db99076b6618c3008f275a1f3acd4f4bb7ad1

Contents?: true

Size: 685 Bytes

Versions: 6

Compression:

Stored size: 685 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"
require "rails_api_logger/inbound_requests_logger_middleware"

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

6 entries across 6 versions & 1 rubygems

Version Path
rails_api_logger-0.2.5 lib/rails_api_logger.rb
rails_api_logger-0.2.4 lib/rails_api_logger.rb
rails_api_logger-0.2.3 lib/rails_api_logger.rb
rails_api_logger-0.2.2 lib/rails_api_logger.rb
rails_api_logger-0.2.1 lib/rails_api_logger.rb
rails_api_logger-0.2.0 lib/rails_api_logger.rb