gds-api-adapters 28.1.1 → 28.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -6
- data/lib/gds_api/railtie.rb +5 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/json_client_test.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9723069f15e906994434db9e846a9d312f7bdb1
|
4
|
+
data.tar.gz: 04a3f4851097ca03fbb130f14f32380fa9ee9d0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da34eae72d2c0fcf451b4db6376aaa74ac268bd1fee74ef6ad541727e626855a7497e34934f77345c09875a9ff873c06b4de6fbc58c4d4c5ac5d0772230c0fbc
|
7
|
+
data.tar.gz: 7fb8ebf8449dc9eeb9c63f26d8eb19bc4203d2056ceffca321d776e64ad0b06d371ab262cacc4bca683c3b16c3e1345efbbcbfb6cd3c51e914582a8fadbd66e1
|
data/README.md
CHANGED
@@ -31,15 +31,19 @@ something that actually logs:
|
|
31
31
|
|
32
32
|
## Middleware for request tracing
|
33
33
|
|
34
|
-
We set a unique header at the cache level called `Govuk-Request-Id
|
35
|
-
|
36
|
-
|
34
|
+
We set a unique header at the cache level called `Govuk-Request-Id`, and also
|
35
|
+
set a header called `Govuk-Original-Url` to identify the original URL
|
36
|
+
requested. If apps make API requests in order to server a user's request, they
|
37
|
+
should pass on these headers, so that we can trace requests across the entire
|
38
|
+
GOV.UK stack.
|
37
39
|
|
38
|
-
`GdsApi::GovukHeaderSniffer` middleware takes care of this. This gem
|
39
|
-
a railtie that configures this middleware for Rails apps without extra
|
40
|
-
Other Rack-based apps should opt-in by adding
|
40
|
+
The `GdsApi::GovukHeaderSniffer` middleware takes care of this. This gem
|
41
|
+
contains a railtie that configures this middleware for Rails apps without extra
|
42
|
+
effort. Other Rack-based apps should opt-in by adding these lines to your
|
43
|
+
`config.ru`:
|
41
44
|
|
42
45
|
use GdsApi::GovukHeaderSniffer, 'HTTP_GOVUK_REQUEST_ID'
|
46
|
+
use GdsApi::GovukHeaderSniffer, 'HTTP_GOVUK_ORIGINAL_URL'
|
43
47
|
|
44
48
|
## Middleware for identifying authenticated users
|
45
49
|
|
data/lib/gds_api/railtie.rb
CHANGED
@@ -7,6 +7,11 @@ module GdsApi
|
|
7
7
|
app.middleware.use GdsApi::GovukHeaderSniffer, 'HTTP_GOVUK_REQUEST_ID'
|
8
8
|
end
|
9
9
|
|
10
|
+
initializer "gds_api.initialize_govuk_original_url_sniffer" do |app|
|
11
|
+
Rails.logger.info "Using middleware GdsApi::GovukHeaderSniffer to sniff for GOVUK-Original-Url header"
|
12
|
+
app.middleware.use GdsApi::GovukHeaderSniffer, 'HTTP_GOVUK_ORIGINAL_URL'
|
13
|
+
end
|
14
|
+
|
10
15
|
initializer "gds_api.initialize_govuk_authenticated_user_sniffer" do |app|
|
11
16
|
Rails.logger.info "Using middleware GdsApi::GovukHeaderSniffer to sniff for X-GOVUK-Authenticated-User header"
|
12
17
|
app.middleware.use GdsApi::GovukHeaderSniffer, 'HTTP_X_GOVUK_AUTHENTICATED_USER'
|
data/lib/gds_api/version.rb
CHANGED
data/test/json_client_test.rb
CHANGED
@@ -702,13 +702,17 @@ class JsonClientTest < MiniTest::Spec
|
|
702
702
|
end
|
703
703
|
|
704
704
|
def test_govuk_headers_are_included_in_requests_if_present
|
705
|
-
|
705
|
+
# set headers which would be set by middleware GovukHeaderSniffer
|
706
|
+
GdsApi::GovukHeaders.set_header(:govuk_request_id, "12345")
|
707
|
+
GdsApi::GovukHeaders.set_header(:govuk_original_url, "http://example.com")
|
708
|
+
|
706
709
|
stub_request(:get, "http://some.other.endpoint/some.json").to_return(:status => 200)
|
707
710
|
|
708
711
|
GdsApi::JsonClient.new.get_json("http://some.other.endpoint/some.json")
|
709
712
|
|
710
713
|
assert_requested(:get, %r{/some.json}) do |request|
|
711
|
-
request.headers['Govuk-Request-Id'] == '12345'
|
714
|
+
request.headers['Govuk-Request-Id'] == '12345' &&
|
715
|
+
request.headers['Govuk-Original-Url'] == 'http://example.com'
|
712
716
|
end
|
713
717
|
end
|
714
718
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 28.
|
4
|
+
version: 28.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|