Skip to content

Commit 85ef2ea

Browse files
authored
Merge pull request #639 from StupidCodeFactory/allow-faraday-customisation
Allow for customisation of the Faraday Adapter
2 parents 3df5025 + f2d9c10 commit 85ef2ea

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

lib/raven/configuration.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class Configuration
3737
# The Faraday adapter to be used. Will default to Net::HTTP when not set.
3838
attr_accessor :http_adapter
3939

40+
# A Proc yeilding the faraday builder allowing for further configuration
41+
# of the faraday adapter
42+
attr_accessor :faraday_builder
43+
4044
# You may provide your own LineCache for matching paths with source files.
4145
# This may be useful if you need to get source code from places other than
4246
# the disk. See Raven::LineCache for the required interface you must implement.

lib/raven/transports/http.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def set_conn
4848
:url => configuration[:server],
4949
:ssl => ssl_configuration
5050
) do |builder|
51+
configuration.faraday_builder.call(builder) if configuration.faraday_builder
5152
builder.response :raise_error
5253
builder.adapter(*adapter)
5354
end

spec/raven/transports/http_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,17 @@
4646

4747
stubs.verify_stubbed_calls
4848
end
49+
50+
it 'allows to customise faraday' do
51+
builder = spy('faraday_builder')
52+
expect(Faraday).to receive(:new).and_yield(builder)
53+
54+
Raven.configure do |config|
55+
config.faraday_builder = proc { |b| b.request :instrumentation }
56+
end
57+
58+
Raven.client.send(:transport)
59+
60+
expect(builder).to have_received(:request).with(:instrumentation)
61+
end
4962
end

0 commit comments

Comments
 (0)