class Johac::Connection::Middleware::PersistentAdapter
Wrapper of {Faraday::Adapter::NetHttpPersistent} adapter that allows for a block to be given when the faraday connection is created. Block is passed the newly created {Net::HTTP::Persistent} instance to be modified if desired.
Allows for configuration of HTTP connection.
@see github.com/lostisland/faraday @see github.com/drbrain/net-http-persistent
Public Class Methods
new(app, &block)
click to toggle source
Extend Faraday::Adapter::NetHttpPersistent's initialize method with an optional block.
@yield [Net::HTTP::Persistent] Stores the passed block for use when
creating a new HTTP connection.
Calls superclass method
# File lib/johac/connection.rb, line 87 def initialize(app, &block) @config_block = block super(app) end
Public Instance Methods
with_net_http_connection(env) { |http| ... }
click to toggle source
Yield HTTP connection to supplied block.
Calls superclass method
# File lib/johac/connection.rb, line 93 def with_net_http_connection(env, &block) http = super(env) { |v| v } @config_block.call(http) if @config_block yield http end