Method: Brine::ClientBuilding#connection_handlers

Defined in:
lib/brine/client_building.rb

#connection_handlersObject

Expose the handlers/middleware that will be wired while constructing a client.

This is represented as list of functions so that it can be more easily customized for unexpected use cases. It should likely be broken up a bit more sensibly and more useful insertion commands added… but it’s likely enough of a power feature and platform specific to leave pretty raw.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/brine/client_building.rb', line 82

def connection_handlers
  @connection_handlers ||= [
    proc do |conn|
      conn.request :json
      if @oauth2
        conn.request :oauth2, @oauth2.token, :token_type => @oauth2.token_type
      end
    end,
    proc do |conn|
      if @logging
        conn.response :logger, nil, :bodies => (@logging.casecmp('DEBUG') == 0)
      end
      conn.response :json, :content_type => /\bjson$/
    end,
    proc{|conn| conn.adapter Faraday.default_adapter }
  ]
end