garage_client 2.1.6 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 876435ec94b293955088ff468b9f15eda5a5f08d
4
- data.tar.gz: 2aa489fb0250350d47c86c6751950d1db5a36743
3
+ metadata.gz: 9e74a44c3a35415ce42c5c5f522ca71cbea0c859
4
+ data.tar.gz: d350897b48c1733a457748f373bb6d5424656474
5
5
  SHA512:
6
- metadata.gz: e7acdb469b6d4493aab2e86669c55c05f2209eea17c03eb9ef7dfc954f871ba8a7d7ed0beb94a451bef03e53a2bffee5480e48efde848c0da50afda07001bebe
7
- data.tar.gz: e772d7c35be9afa30b6d04cab2abb3df81808e5429cccd1b9f48aa18662d143ba160ea60c560199aebe8bbd9cda1525b65f43103689ffc2437d5c15f58e98740
6
+ metadata.gz: 51bef033014e9b7330d671097ba96188b31b6886cde1a5bb51eec2bd73ac8a80854dd20f5dc61f3615a8b2c5f06aeed4d2ce2e63c04fb91b627b75f27ca56745
7
+ data.tar.gz: 3d9682ba319b2948e289504fe610e1adf3febd032acce0cf6a1b55baef73deae037b276ced1b037ecd4de88ff74ccb8a3b47009c37f1c544aa8d59752f607f2f
data/lib/garage_client.rb CHANGED
@@ -8,6 +8,7 @@ require 'garage_client/configuration'
8
8
  require 'garage_client/error'
9
9
  require 'garage_client/request'
10
10
  require 'garage_client/request/json_encoded'
11
+ require 'garage_client/request/propagate_request_id'
11
12
  require 'garage_client/response'
12
13
  require 'garage_client/response/cacheable'
13
14
  require 'garage_client/response/raise_http_exception'
@@ -67,6 +67,7 @@ module GarageClient
67
67
  # Request Middlewares
68
68
  builder.use Faraday::Request::Multipart
69
69
  builder.use GarageClient::Request::JsonEncoded
70
+ builder.use GarageClient::Request::PropagateRequestId
70
71
 
71
72
  # Low-level Middlewares
72
73
  apply_auth_middleware builder
@@ -0,0 +1,12 @@
1
+ module GarageClient
2
+ module Request
3
+ class PropagateRequestId < Faraday::Middleware
4
+ def call(env)
5
+ if Thread.current[:request_id] && !env[:request_headers]["HTTP_X_REQUEST_ID"]
6
+ env[:request_headers]["HTTP_X_REQUEST_ID"] = Thread.current[:request_id]
7
+ end
8
+ @app.call(env)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module GarageClient
2
- VERSION = '2.1.6'
2
+ VERSION = '2.1.7'
3
3
  end
@@ -0,0 +1,43 @@
1
+ require "spec_helper"
2
+
3
+ describe GarageClient::Request::PropagateRequestId do
4
+ let(:client) do
5
+ GarageClient::Client.new
6
+ end
7
+
8
+ around do |example|
9
+ original = Thread.current[:request_id]
10
+ Thread.current[:request_id] = 'request_id'
11
+ example.run
12
+ Thread.current[:request_id] = original
13
+ end
14
+
15
+ it 'sends request_id via header' do
16
+ stub_get("/examples").with(headers: { 'HTTP_X_REQUEST_ID' => 'request_id' })
17
+ expect { client.get("/examples") }.not_to raise_error
18
+ end
19
+
20
+ context 'without request_id' do
21
+ before do
22
+ Thread.current[:request_id] = nil
23
+ end
24
+
25
+ it 'does not send request_id via header' do
26
+ stub_get("/examples").with do |request|
27
+ !request.headers.include?('HTTP_X_REQUEST_ID')
28
+ end
29
+ expect { client.get("/examples") }.not_to raise_error
30
+ end
31
+ end
32
+
33
+ context 'if already has request_id' do
34
+ let(:client) do
35
+ GarageClient::Client.new(headers: { 'HTTP_X_REQUEST_ID' => 'another_id' })
36
+ end
37
+
38
+ it 'does not overwrite request_id' do
39
+ stub_get("/examples").with(headers: { 'HTTP_X_REQUEST_ID' => 'another_id' })
40
+ expect { client.get("/examples") }.not_to raise_error
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garage_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 2.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cookpad Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-22 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -203,6 +203,7 @@ files:
203
203
  - lib/garage_client/error.rb
204
204
  - lib/garage_client/request.rb
205
205
  - lib/garage_client/request/json_encoded.rb
206
+ - lib/garage_client/request/propagate_request_id.rb
206
207
  - lib/garage_client/resource.rb
207
208
  - lib/garage_client/response.rb
208
209
  - lib/garage_client/response/cacheable.rb
@@ -220,6 +221,7 @@ files:
220
221
  - spec/garage_client/configuration_spec.rb
221
222
  - spec/garage_client/error_spec.rb
222
223
  - spec/garage_client/request/json_encoded_spec.rb
224
+ - spec/garage_client/request/propagate_request_id_spec.rb
223
225
  - spec/garage_client/resource_spec.rb
224
226
  - spec/garage_client/response_spec.rb
225
227
  - spec/garage_client_spec.rb
@@ -243,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
245
  version: '0'
244
246
  requirements: []
245
247
  rubyforge_project:
246
- rubygems_version: 2.4.5.1
248
+ rubygems_version: 2.4.8
247
249
  signing_key:
248
250
  specification_version: 4
249
251
  summary: Ruby client library for the Garage API
@@ -260,7 +262,9 @@ test_files:
260
262
  - spec/garage_client/configuration_spec.rb
261
263
  - spec/garage_client/error_spec.rb
262
264
  - spec/garage_client/request/json_encoded_spec.rb
265
+ - spec/garage_client/request/propagate_request_id_spec.rb
263
266
  - spec/garage_client/resource_spec.rb
264
267
  - spec/garage_client/response_spec.rb
265
268
  - spec/garage_client_spec.rb
266
269
  - spec/spec_helper.rb
270
+ has_rdoc: