Class: AppMap::Handler::Rails::RequestHandler::HTTPServerResponse

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

Constant Summary

Constants inherited from Event::MethodEvent

Event::MethodEvent::MAX_ARRAY_ENUMERATION, Event::MethodEvent::MAX_HASH_ENUMERATION, Event::MethodEvent::MAX_STRING_LENGTH

Constants included from ValueInspector

ValueInspector::MAX_ARRAY_ELEMENTS, ValueInspector::MAX_DEPTH

Instance Attribute Summary collapse

Attributes inherited from Event::MethodReturn

#exceptions, #return_value

Attributes inherited from Event::MethodReturnIgnoreValue

#elapsed, #elapsed_instrumentation, #parent_id

Attributes inherited from Event::MethodEventStruct

#event, #id, #thread_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Event::MethodEvent

add_schema, add_size, custom_display_string, default_display_string, display_string, encode_display_string, #ready?

Methods included from ValueInspector

#best_class_name, #detect_schema, #detect_size

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



74
75
76
# File 'lib/appmap/handler/rails/request_handler.rb', line 74

def headers
  @headers
end

#statusObject

Returns the value of attribute status.



74
75
76
# File 'lib/appmap/handler/rails/request_handler.rb', line 74

def status
  @status
end

Class Method Details

.build_from_invocation(parent_id, return_value, elapsed, response, event: HTTPServerResponse.new) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/appmap/handler/rails/request_handler.rb', line 77

def build_from_invocation(parent_id, return_value, elapsed, response, event: HTTPServerResponse.new)
  event ||= HTTPServerResponse.new

  status = response[:status] || response.status
  event.status = status if valid_http_status?(status)
  event.headers = (response[:headers] || response.headers).dup
  AppMap::Event::MethodReturn.build_from_invocation parent_id, return_value, nil, elapsed: elapsed, event: event, parameter_schema: true
end

.valid_http_status?(status) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/appmap/handler/rails/request_handler.rb', line 87

def self.valid_http_status?(status)
  status.is_a?(Integer) && status >= 100 && status < 600
end

Instance Method Details

#to_hObject



91
92
93
94
95
96
97
98
# File 'lib/appmap/handler/rails/request_handler.rb', line 91

def to_h
  super.tap do |h|
    h[:http_server_response] = {
      status_code: status,
      headers: headers
    }.compact
  end
end