Class: Timber::Events::HTTPServerRequest
- Inherits:
-
Timber::Event
- Object
- Timber::Event
- Timber::Events::HTTPServerRequest
- Defined in:
- lib/timber/events/http_server_request.rb
Overview
This event should be installed automatically through integrations, such as the Integrations::ActionController::LogSubscriber integration.
The HTTP server request event tracks incoming HTTP requests to your HTTP server. Such as unicorn, webrick, puma, etc.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#query_string ⇒ Object
readonly
Returns the value of attribute query_string.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
-
#initialize(attributes) ⇒ HTTPServerRequest
constructor
A new instance of HTTPServerRequest.
- #message ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(attributes) ⇒ HTTPServerRequest
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/timber/events/http_server_request.rb', line 12 def initialize(attributes) @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] @query_string = Util::HTTPEvent.normalize_query_string(attributes[:query_string]) @scheme = attributes[:scheme] || raise(ArgumentError.new(":scheme is required")) @request_id = attributes[:request_id] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/timber/events/http_server_request.rb', line 9 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/timber/events/http_server_request.rb', line 9 def headers @headers end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/timber/events/http_server_request.rb', line 9 def host @host end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/timber/events/http_server_request.rb', line 9 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/timber/events/http_server_request.rb', line 9 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/timber/events/http_server_request.rb', line 9 def port @port end |
#query_string ⇒ Object (readonly)
Returns the value of attribute query_string.
9 10 11 |
# File 'lib/timber/events/http_server_request.rb', line 9 def query_string @query_string end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
9 10 11 |
# File 'lib/timber/events/http_server_request.rb', line 9 def request_id @request_id end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
9 10 11 |
# File 'lib/timber/events/http_server_request.rb', line 9 def scheme @scheme end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
29 30 31 |
# File 'lib/timber/events/http_server_request.rb', line 29 def as_json( = {}) {:http_server_request => to_hash} end |
#message ⇒ Object
33 34 35 |
# File 'lib/timber/events/http_server_request.rb', line 33 def 'Started %s "%s"' % [method, path] end |
#to_hash ⇒ Object Also known as: to_h
23 24 25 26 |
# File 'lib/timber/events/http_server_request.rb', line 23 def to_hash {body: body, headers: headers, host: host, method: method, path: path, port: port, query_string: query_string, request_id: request_id, scheme: scheme} end |