Class: VCR::Middleware::Faraday

Inherits:
Object
  • Object
show all
Includes:
Deprecations::Middleware::Faraday
Defined in:
lib/vcr/middleware/faraday.rb

Overview

Note:

You can either insert this middleware into the Faraday middleware stack yourself or configure Configuration#hook_into to hook into ‘:faraday`.

Faraday middleware that VCR uses to record and replay HTTP requests made through Faraday.

Defined Under Namespace

Classes: RequestHandler

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Faraday

Constructs a new instance of the Faraday middleware.

Parameters:

  • app (#call)

    the faraday app



21
22
23
24
# File 'lib/vcr/middleware/faraday.rb', line 21

def initialize(app)
  super
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Handles the HTTP request being made through Faraday

Parameters:

  • env (Hash)

    the Faraday request env hash



29
30
31
32
# File 'lib/vcr/middleware/faraday.rb', line 29

def call(env)
  return @app.call(env) if VCR.library_hooks.disabled?(:faraday)
  RequestHandler.new(@app, env).handle
end

#closeObject

Close any persistent connections.



35
36
37
# File 'lib/vcr/middleware/faraday.rb', line 35

def close
  @app.close if @app.respond_to?(:close)
end