Sha256: b071e270a3100540d210b04cddd54a2c2259dfebbc1199c5d1fc2004c849aeec

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

require "timber/context"

module Timber
  module Contexts
    # @private
    class HTTP < Context
      attr_reader :host, :method, :path, :remote_addr, :request_id

      def initialize(attributes)
        @host = attributes[:host]
        @method = attributes[:method]
        @path = attributes[:path]
        @remote_addr = attributes[:remote_addr]
        @request_id = attributes[:request_id]
      end

      # Builds a hash representation containing simple objects, suitable for serialization (JSON).
      def to_hash
        @to_hash ||= {
          http: Util::NonNilHashBuilder.build do |h|
            h.add(:host, host)
            h.add(:method, method)
            h.add(:path, path)
            h.add(:remote_addr, remote_addr)
            h.add(:request_id, request_id)
          end
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
timber-3.0.1 lib/timber/contexts/http.rb
timber-3.0.0 lib/timber/contexts/http.rb