Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Add support for before_delivery in get requests
Browse files Browse the repository at this point in the history
  • Loading branch information
bswinnerton committed Apr 8, 2018
1 parent 45d6348 commit 5bf6a9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,11 @@ def shorten_url(url)
def http_get(url = nil, params = {}, headers = {})
raise_config_error("Invalid scheme") unless permitted_transport?(url)
url = url.strip if url

if pre_delivery_callbacks.any?
pre_delivery_callbacks.each { |c| c.call(url, nil, headers, params) }
end

http.get do |req|
req.url(url) if url
req.params.update(params) if params
Expand Down
4 changes: 2 additions & 2 deletions test/service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ def test_multiple_before_delivery_callbacks
headers['EDITED-IN-BEFORE-DELIVERY-2'] = true
end

@stubs.post '/' do |env|
@stubs.get '/' do |env|
assert_equal true, env[:request_headers]['Edited-In-Before-Delivery-1']
assert_equal true, env[:request_headers]['Edited-In-Before-Delivery-2']
[200, {'X-Test' => 'success'}, 'OK']
end

@service.http_post('/', payload)
@service.http_get('/')

@service.http_calls.each do |env|
assert_equal 200, env[:response][:status]
Expand Down

0 comments on commit 5bf6a9d

Please sign in to comment.