Skip to content

Commit 7642d22

Browse files
committed
Merge pull request piotrmurach#264 from zacksiri/master
Can add custom stack to middleware fixes piotrmurach#227
2 parents 26829d1 + 0c9ae37 commit 7642d22

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ You can now configure cache parameters as follows
384384

385385
```ruby
386386
Github.configure do |config|
387-
config.stack do |builder|
387+
config.stack = proc do |builder|
388388
builder.use Faraday::HttpCache, store: Rails.cache
389389
end
390390
end

lib/github_api/connection.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ def stack(options = {})
5959
def connection(api, options = {})
6060
connection_options = default_options(options)
6161
clear_cache unless options.empty?
62-
builder = api.stack ? api.stack : stack(options.merge!(api: api))
63-
connection_options.merge!(builder: builder)
62+
connection_options.merge!(builder: stack(options.merge!(api: api)))
6463
connection_options.deep_merge!(options[:connection_options]) if options[:connection_options]
6564
if ENV['DEBUG']
6665
p "Connection options : \n"

lib/github_api/middleware.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def self.default(options = {})
2424
builder.use Github::Response::Jsonize
2525
builder.use Github::Response::AtomParser
2626
end
27+
if api.stack
28+
api.stack.call(builder)
29+
end
2730
builder.use Github::Response::RaiseError
2831
builder.adapter options[:adapter]
2932
end

0 commit comments

Comments
 (0)