Sha256: e6c04236e6fa40f8e211ae325a994e0c96dd2318be33882ccf80ba9c2a8198bd

Contents?: true

Size: 842 Bytes

Versions: 18

Compression:

Stored size: 842 Bytes

Contents

require "logtail/context"

module Logtail
  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

18 entries across 18 versions & 2 rubygems

Version Path
logtail-ruby-0.1.3 lib/logtail/contexts/http.rb
logtail-0.1.13 lib/logtail/contexts/http.rb
logtail-0.1.12 lib/logtail/contexts/http.rb
logtail-0.1.11 lib/logtail/contexts/http.rb
logtail-0.1.10 lib/logtail/contexts/http.rb
logtail-0.1.9 lib/logtail/contexts/http.rb
logtail-0.1.8 lib/logtail/contexts/http.rb
logtail-0.1.7 lib/logtail/contexts/http.rb
logtail-0.1.6 lib/logtail/contexts/http.rb
logtail-0.1.5 lib/logtail/contexts/http.rb
logtail-0.1.4 lib/logtail/contexts/http.rb
logtail-0.1.3 lib/logtail/contexts/http.rb
logtail-0.1.2 lib/logtail/contexts/http.rb
logtail-0.1.1 lib/logtail/contexts/http.rb
logtail-0.1.0 lib/logtail/contexts/http.rb
logtail-ruby-0.1.2 lib/logtail/contexts/http.rb
logtail-ruby-0.1.1 lib/logtail/contexts/http.rb
logtail-ruby-0.1.0 lib/logtail/contexts/http.rb