Class: DevSuite::RequestLogger::Extractor::NetHttp
- Inherits:
-
Base
- Object
- Utils::Construct::Component::Base
- Base
- DevSuite::RequestLogger::Extractor::NetHttp
- Defined in:
- lib/dev_suite/request_logger/extractor/net_http.rb
Constant Summary collapse
- COMPONENT_KEY =
::Net::HTTP
Instance Method Summary collapse
-
#extract_request(http, request) ⇒ Object
Extracts the request details from a Net::HTTP request object.
-
#extract_response(_http, response) ⇒ Response
Extracts the response details from a Net::HTTP response object.
Methods inherited from Utils::Construct::Component::Base
Instance Method Details
#extract_request(http, request) ⇒ Object
Extracts the request details from a Net::HTTP request object
12 13 14 15 16 17 18 19 20 |
# File 'lib/dev_suite/request_logger/extractor/net_http.rb', line 12 def extract_request(http, request) Request.new( method: request.method, url: build_url(http, request), headers: request.each_header.to_h, cookies: (request), body: request.body, ) end |
#extract_response(_http, response) ⇒ Response
Extracts the response details from a Net::HTTP response object
26 27 28 29 30 31 32 33 34 |
# File 'lib/dev_suite/request_logger/extractor/net_http.rb', line 26 def extract_response(_http, response) Response.new( status: response.code.to_i, message: response., headers: response.each_header.to_h, body: response.body, response_time: calculate_response_time(response), ) end |