Class: SpecForge::HTTP::Backend

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

Overview

Low-level HTTP client wrapper around Faraday

Backend provides methods for each HTTP verb and handles the actual communication with the server. It's used internally by HTTP::Client.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBackend

Creates a new HTTP backend with a Faraday connection



24
25
26
# File 'lib/spec_forge/http/backend.rb', line 24

def initialize
  @connection = Faraday.new
end

Instance Attribute Details

#connectionFaraday::Connection (readonly)

The configured Faraday connection

Returns:

  • (Faraday::Connection)


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

def connection
  @connection
end

Instance Method Details

#deleteFaraday::Response

Executes a DELETE request to <base_url>/<provided_url>

Parameters:

  • options (Hash)

    a customizable set of options

Returns:

  • (Faraday::Response)

    The HTTP response



39
40
41
# File 'lib/spec_forge/http/backend.rb', line 39

def delete(**)
  run_http_method(:delete, **)
end

#getFaraday::Response

Executes a GET request to <base_url>/<provided_url>

Parameters:

  • options (Hash)

    a customizable set of options

Returns:

  • (Faraday::Response)

    The HTTP response



54
55
56
# File 'lib/spec_forge/http/backend.rb', line 54

def get(**)
  run_http_method(:get, **)
end

#patchFaraday::Response

Executes a PATCH request to <base_url>/<provided_url>

Parameters:

  • options (Hash)

    a customizable set of options

Returns:

  • (Faraday::Response)

    The HTTP response



69
70
71
# File 'lib/spec_forge/http/backend.rb', line 69

def patch(**)
  run_http_method(:patch, **)
end

#postFaraday::Response

Executes a POST request to <base_url>/<provided_url>

Parameters:

  • options (Hash)

    a customizable set of options

Returns:

  • (Faraday::Response)

    The HTTP response



84
85
86
# File 'lib/spec_forge/http/backend.rb', line 84

def post(**)
  run_http_method(:post, **)
end

#putFaraday::Response

Executes a PUT request to <base_url>/<provided_url>

Parameters:

  • options (Hash)

    a customizable set of options

Returns:

  • (Faraday::Response)

    The HTTP response



99
100
101
# File 'lib/spec_forge/http/backend.rb', line 99

def put(**)
  run_http_method(:put, **)
end