Class: Timber::Events::HTTPServerRequest

Inherits:
Timber::Event
  • Object
show all
Defined in:
lib/timber/events/http_server_request.rb

Overview

Note:

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

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/timber/events/http_server_request.rb', line 9

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/timber/events/http_server_request.rb', line 9

def headers
  @headers
end

#hostObject (readonly)

Returns the value of attribute host.



9
10
11
# File 'lib/timber/events/http_server_request.rb', line 9

def host
  @host
end

#methodObject (readonly)

Returns the value of attribute method.



9
10
11
# File 'lib/timber/events/http_server_request.rb', line 9

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/timber/events/http_server_request.rb', line 9

def path
  @path
end

#portObject (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_stringObject (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_idObject (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

#schemeObject (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(_options = {})
  {:http_server_request => to_hash}
end

#messageObject



33
34
35
# File 'lib/timber/events/http_server_request.rb', line 33

def message
  'Started %s "%s"' % [method, path]
end

#to_hashObject 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