Class: SpecForge::HTTP::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_forge/http/client.rb

Overview

High-level HTTP client for executing requests

Client wraps Backend and provides a simple interface for executing HTTP::Request objects and returning responses.

Instance Method Summary collapse

Constructor Details

#initializeClient

Creates a new HTTP client with a backend



17
18
19
# File 'lib/spec_forge/http/client.rb', line 17

def initialize
  @backend = Backend.new
end

Instance Method Details

#perform(request) ⇒ Faraday::Response

Executes an HTTP request and returns the response

Parameters:

Returns:

  • (Faraday::Response)

    The HTTP response



28
29
30
31
32
33
34
35
36
37
# File 'lib/spec_forge/http/client.rb', line 28

def perform(request)
  @backend.public_send(
    request.http_verb.downcase,
    base_url: request.base_url,
    url: request.url.delete_prefix("/"),
    headers: request.headers,
    query: request.query,
    body: request.body
  )
end