rack-json_response_wrapper 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b045582186350a205ba09cd1b9ef961283d4bda
4
- data.tar.gz: 1bab96a3396b352f8c8149180a1b00da138aa996
3
+ metadata.gz: 627f275224585a9e311092f118d87417e9cc0f24
4
+ data.tar.gz: 6c6dea76b77f3ac7bd03fb36dc4fd82b50d92591
5
5
  SHA512:
6
- metadata.gz: 8ec0543023c93957f5f78e54a78d674dda6cc98fe432f6fa69f0d15d7c1f6eaaab937be283a6fe5f44e13ba9790c61caa6679ba637d932e669f2e2daab7e4040
7
- data.tar.gz: e21ce554077dc7f3e4c94c27e93f92bdaf9a765743c2b77ee013d3709009fce5a6d04034956f4d0fbfb92c6d9a736c3d5f3852f2a4faf6f6ce4fff250147b630
6
+ metadata.gz: e224b62a3246391cb8b93c7c34186359f08c569088953a2ad6d4b552b4519ac8bd86a8d29a5ca775aa2653cedfe367a7e371b8606212d068f0159cdc9ae47bad
7
+ data.tar.gz: 179308da01f784339d4bef718caa01e1440708adfc1da91d3ad9dcbfd48882414431e0facdb9bc4f97f6471a91750e5a6871b63d3d4078c4a8971174eff7d38d
@@ -20,15 +20,20 @@ module Rack
20
20
  response_header = response[1]
21
21
 
22
22
  is_json = response_header['Content-Type'].match(/application\/json/)
23
- wants_wrap = env.include? 'X-WRAP-RESPONSE'
23
+ wants_wrap = env.include?('HTTP_X_WRAP_RESPONSE') ||
24
+ env.include?('X-WRAP-RESPONSE')
24
25
 
25
26
  is_json && wants_wrap
26
27
  end
27
28
 
28
29
  def wrap_response(response)
29
- response_body = response[2].reduce(&:concat)
30
30
  response_header = response[1]
31
31
 
32
+ response_body = ''
33
+ response[2].each do |segment|
34
+ response_body += segment
35
+ end
36
+
32
37
  response_obj = JSON.parse(response_body)
33
38
 
34
39
  wrapped_obj = {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-json_response_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - g. nicholas d'andrea