Class: DevSuite::RequestLogger::Extractor::Faraday

Inherits:
Base show all
Defined in:
lib/dev_suite/request_logger/extractor/faraday.rb

Constant Summary collapse

COMPONENT_KEY =
::Faraday::Connection

Instance Method Summary collapse

Methods inherited from Utils::Construct::Component::Base

component_key

Instance Method Details

#extract_request(connection, request) ⇒ Object

Extracts the request details from a Faraday request object

Parameters:

  • _instance (Faraday::Connection)

    The instance of the Faraday client that is making the request

  • request (Faraday::Env)

    The request object that is being made



12
13
14
15
16
17
18
19
20
# File 'lib/dev_suite/request_logger/extractor/faraday.rb', line 12

def extract_request(connection, request)
  Request.new(
    method: request.method.to_s.upcase,
    url: build_url(connection),
    headers: build_headers_from_request(request),
    cookies: build_cookies(request),
    body: request.body,
  )
end

#extract_response(_connection, response) ⇒ Object

Extracts the response details from a Faraday response object

Parameters:

  • _instance (Faraday::Connection)

    The instance of the Faraday client that received the response

  • response (Faraday::Env)

    The response object received



25
26
27
28
29
30
31
32
# File 'lib/dev_suite/request_logger/extractor/faraday.rb', line 25

def extract_response(_connection, response)
  Response.new(
    status: response.status,
    message: response.reason_phrase || "",
    headers: build_headers_from_response(response),
    body: response.body,
  )
end