lib/timber/events/http_server_request.rb in timber-2.0.24 vs lib/timber/events/http_server_request.rb in timber-2.1.0.rc1

- old
+ new

@@ -1,5 +1,8 @@ +require "timber/event" +require "timber/util" + module Timber module Events # The HTTP server request event tracks incoming HTTP requests to your HTTP server. # Such as unicorn, webrick, puma, etc. # @@ -8,10 +11,11 @@ class HTTPServerRequest < Timber::Event attr_reader :body, :headers, :host, :method, :path, :port, :query_string, :request_id, :scheme def initialize(attributes) + @body = attributes[:body] && Util::HTTPEvent.normalize_body(attributes[:body]) @headers = Util::HTTPEvent.normalize_headers(attributes[:headers]) @host = attributes[:host] || raise(ArgumentError.new(":host is required")) @method = Util::HTTPEvent.normalize_method(attributes[:method]) || raise(ArgumentError.new(":method is required")) @path = attributes[:path] @port = attributes[:port] @@ -24,9 +28,10 @@ {body: body, headers: headers, host: host, method: method, path: path, port: port, query_string: query_string, request_id: request_id, scheme: scheme} end alias to_h to_hash + # Builds a hash representation of containing simply objects, suitable for serialization. def as_json(_options = {}) {:http_server_request => to_hash} end def message \ No newline at end of file