Class: AppMap::Rails::RequestHandler::HTTPServerRequest

Inherits:
Event::MethodEvent show all
Defined in:
lib/appmap/rails/request_handler.rb

Constant Summary

Constants inherited from Event::MethodEvent

Event::MethodEvent::LIMIT

Instance Attribute Summary collapse

Attributes inherited from Event::MethodEventStruct

#event, #id, #thread_id

Instance Method Summary collapse

Methods inherited from Event::MethodEvent

build_from_invocation, display_string, object_properties

Constructor Details

#initialize(request) ⇒ HTTPServerRequest

Returns a new instance of HTTPServerRequest.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/appmap/rails/request_handler.rb', line 32

def initialize(request)
  super AppMap::Event.next_id_counter, :call, Thread.current.object_id

  self.request_method = request.request_method
  self.normalized_path_info = normalized_path(request)
  self.mime_type = request.headers['Content-Type']
  self.headers = RequestHandler.selected_headers(request.env)
  self.authorization = request.headers['Authorization']
  self.path_info = request.path_info.split('?')[0]
  # ActionDispatch::Http::ParameterFilter is deprecated
  parameter_filter_cls = \
    if defined?(ActiveSupport::ParameterFilter)
      ActiveSupport::ParameterFilter
    else
      ActionDispatch::Http::ParameterFilter
    end
  self.params = parameter_filter_cls.new(::Rails.application.config.filter_parameters).filter(request.params)
end

Instance Attribute Details

#authorizationObject

Returns the value of attribute authorization.



30
31
32
# File 'lib/appmap/rails/request_handler.rb', line 30

def authorization
  @authorization
end

#headersObject

Returns the value of attribute headers.



30
31
32
# File 'lib/appmap/rails/request_handler.rb', line 30

def headers
  @headers
end

#mime_typeObject

Returns the value of attribute mime_type.



30
31
32
# File 'lib/appmap/rails/request_handler.rb', line 30

def mime_type
  @mime_type
end

#normalized_path_infoObject

Returns the value of attribute normalized_path_info.



30
31
32
# File 'lib/appmap/rails/request_handler.rb', line 30

def normalized_path_info
  @normalized_path_info
end

#paramsObject

Returns the value of attribute params.



30
31
32
# File 'lib/appmap/rails/request_handler.rb', line 30

def params
  @params
end

#path_infoObject

Returns the value of attribute path_info.



30
31
32
# File 'lib/appmap/rails/request_handler.rb', line 30

def path_info
  @path_info
end

#request_methodObject

Returns the value of attribute request_method.



30
31
32
# File 'lib/appmap/rails/request_handler.rb', line 30

def request_method
  @request_method
end

Instance Method Details

#to_hObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/appmap/rails/request_handler.rb', line 51

def to_h
  super.tap do |h|
    h[:http_server_request] = {
      request_method: request_method,
      path_info: path_info,
      mime_type: mime_type,
      normalized_path_info: normalized_path_info,
      authorization: authorization,
      headers: headers,
    }.compact

    h[:message] = params.keys.map do |key|
      val = params[key]
      {
        name: key,
        class: val.class.name,
        value: self.class.display_string(val),
        object_id: val.__id__,
      }.tap do |message|
        properties = object_properties(val)
        message[:properties] = properties if properties
      end
    end
  end
end