apiphobic-middleware 1.2.0 → 1.3.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/apiphobic/matchers/version.rb +2 -2
- data/lib/apiphobic/middleware/version.rb +1 -1
- data/lib/apiphobic/requests/accept_header.rb +6 -0
- data/lib/apiphobic/requests/transform_json_api.rb +2 -2
- data/lib/apiphobic/responses/transform_json_api.rb +15 -5
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38f3144a28a7e5930de852652b7c9a41687dbc2fb2fd92b85e46c1eaa3bd68e5
|
4
|
+
data.tar.gz: 0d936500afb0ef3efd63978fbcf7bfc00bccfcfd7f6a2228cddcfa83e7dc3a7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efcb56a6173466a943720ae94eb095ece3f6c9aab8dffca330601976f95d820427d162ff6ffcdf7a840ca667ea2d25b5584c9561107665b1b8f74f32f2fec6dd
|
7
|
+
data.tar.gz: b817f214a07895839909625b838d6007d67a8bbf2f01537b9ccdf9359d4ac131cecf0459311d316aea865dd4a187914082db3574db0142d4cf0a4c5b259be330
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -22,8 +22,8 @@ class Version
|
|
22
22
|
self.version_constraint = version_constraint
|
23
23
|
end
|
24
24
|
|
25
|
-
def matches?(
|
26
|
-
self.request =
|
25
|
+
def matches?(raw_request)
|
26
|
+
self.request = ::Apiphobic::Requests::AcceptHeader.resolve(raw_request)
|
27
27
|
self.accept_header = ::Apiphobic::AcceptHeader.new(request.accept_header,
|
28
28
|
application_name: application_name)
|
29
29
|
|
@@ -13,6 +13,12 @@ class AcceptHeader
|
|
13
13
|
self.request = request
|
14
14
|
end
|
15
15
|
|
16
|
+
def self.resolve(request)
|
17
|
+
return request if request.class == self
|
18
|
+
|
19
|
+
new(request)
|
20
|
+
end
|
21
|
+
|
16
22
|
def accept_header
|
17
23
|
if accept_header_from_header.valid? || accept_header_from_params.invalid?
|
18
24
|
raw_accept_header_from_header
|
@@ -21,7 +21,7 @@ class TransformJsonApi
|
|
21
21
|
|
22
22
|
if has_content? && json?
|
23
23
|
request[content_parameter] = request_body_with_underscored_json_keys
|
24
|
-
request['CONTENT_LENGTH'] = content_length
|
24
|
+
request['CONTENT_LENGTH'] = content_length.to_s
|
25
25
|
end
|
26
26
|
|
27
27
|
request
|
@@ -67,7 +67,7 @@ class TransformJsonApi
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def underscored_request_json
|
70
|
-
JSON.dump(underscored_request_hash)
|
70
|
+
@underscored_request_json ||= JSON.dump(underscored_request_hash)
|
71
71
|
end
|
72
72
|
|
73
73
|
def underscored_request_hash
|
@@ -30,6 +30,14 @@ class TransformJsonApi
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def transformed_body
|
33
|
+
if content_parameter == 'rack.input'
|
34
|
+
StringIO.new(transformed_json_body)
|
35
|
+
else
|
36
|
+
transformed_json_body
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def transformed_json_body
|
33
41
|
return request_body if request_body == '' || request_body.nil?
|
34
42
|
|
35
43
|
relationships = request_hash.dig('data', 'relationships') || {}
|
@@ -51,11 +59,13 @@ class TransformJsonApi
|
|
51
59
|
end
|
52
60
|
|
53
61
|
def request_body
|
54
|
-
if headers['rack.input']
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
62
|
+
@request_body ||= if headers['rack.input']
|
63
|
+
headers['rack.input'].read
|
64
|
+
else
|
65
|
+
headers['RACK_INPUT'].to_s
|
66
|
+
end
|
67
|
+
ensure
|
68
|
+
headers['rack.input']&.rewind
|
59
69
|
end
|
60
70
|
end
|
61
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiphobic-middleware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thegranddesign
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
Y2GAoHKstmfIVhc4XHOPpmTd2o/C29O9oaRgjrkfQEhF/KvJ/PhoV5hvokzsCyI5
|
32
32
|
iUeXPfvrGD/itYIBCgk+fnzyQQ4QtE5hTQaWQ3o2
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2018-05-
|
34
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: apple_core
|
metadata.gz.sig
CHANGED
Binary file
|