api_valve 0.5.0 → 0.5.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6a3b6b23568f00882c8cf08a5d2150096819307ab303b20513008d2d995b6c8
|
4
|
+
data.tar.gz: 9a1c6d19d2b7a7f0a6738f163906ce1433473ad5c94b95fe07b5a885c2b68f14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0719eeff6965648630a5676e76d0fcf24b458ac76d929485bf970953c58fc353a672cbfe2efa448e9d77e455d56d6d47972c1d9b07109c73d63b1fd36e3111c2'
|
7
|
+
data.tar.gz: 99db0790a2cbea77314f803c8baeb75f833cd39ae1fe5040ee0051c08df73e61bfdfcefed2508ca782ede4928a2b5db547aa29af6c6b4096d5fd9be12e6ae45d
|
data/lib/api_valve/forwarder.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module ApiValve
|
2
2
|
# This class is responsible for forwarding the HTTP request to the
|
3
|
-
# designated endpoint. It is
|
3
|
+
# designated endpoint. It is instantiated once per Proxy with relevant
|
4
4
|
# options, and called from the router.
|
5
5
|
|
6
6
|
class Forwarder
|
@@ -21,7 +21,7 @@ module ApiValve
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# Takes the original rack request with optional options and returns a rack response
|
24
|
-
#
|
24
|
+
# Instantiates the Request and Response classes and wraps them around the original
|
25
25
|
# request and response.
|
26
26
|
def call(original_request, local_options = {})
|
27
27
|
request = build_request(original_request, request_options.deep_merge(local_options))
|
@@ -44,7 +44,7 @@ module ApiValve
|
|
44
44
|
original_response,
|
45
45
|
options.merge(
|
46
46
|
target_prefix: @target_prefix,
|
47
|
-
local_prefix:
|
47
|
+
local_prefix: original_request.env['SCRIPT_NAME']
|
48
48
|
)
|
49
49
|
)
|
50
50
|
end
|
@@ -76,9 +76,9 @@ module ApiValve
|
|
76
76
|
ApiValve.logger.info do
|
77
77
|
format(
|
78
78
|
'-> %<method>s %<endpoint>s%<path>s',
|
79
|
-
method:
|
79
|
+
method: request.method.upcase,
|
80
80
|
endpoint: endpoint,
|
81
|
-
path:
|
81
|
+
path: request.path
|
82
82
|
)
|
83
83
|
end
|
84
84
|
end
|
@@ -88,7 +88,7 @@ module ApiValve
|
|
88
88
|
format(
|
89
89
|
'<- %<status>s in %<ms>dms',
|
90
90
|
status: response.status,
|
91
|
-
ms:
|
91
|
+
ms: elapsed_time * 1000
|
92
92
|
)
|
93
93
|
end
|
94
94
|
end
|
@@ -10,7 +10,7 @@ module ApiValve
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def permission_handler
|
13
|
-
permission_handler_klass.instance(
|
13
|
+
permission_handler_klass.instance(original_request, permission_handler_options)
|
14
14
|
end
|
15
15
|
|
16
16
|
def permission_handler_klass
|
@@ -18,10 +18,14 @@ module ApiValve
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def permission_handler_options
|
21
|
-
|
21
|
+
options[:permission_handler] || {}
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
attr_reader :request, :options
|
26
|
+
|
27
|
+
delegate :env, to: :request
|
28
|
+
|
25
29
|
# Returns an instance of the PermissionHandler, cached in the request env
|
26
30
|
# This allows re-use of the PermissionHandler by both Request and Response instances
|
27
31
|
def self.instance(request, options)
|
@@ -11,7 +11,7 @@ module ApiValve
|
|
11
11
|
class Forwarder::Response
|
12
12
|
include Forwarder::PermissionHandler::RequestIntegration
|
13
13
|
|
14
|
-
attr_reader :original_request, :original_response
|
14
|
+
attr_reader :original_request, :original_response, :options
|
15
15
|
|
16
16
|
WHITELISTED_HEADERS = %w(
|
17
17
|
Cache-Control
|
data/lib/api_valve/proxy.rb
CHANGED
@@ -54,8 +54,8 @@ module ApiValve
|
|
54
54
|
def forwarder_config(config)
|
55
55
|
{
|
56
56
|
permission_handler: {klass: permission_handler},
|
57
|
-
request:
|
58
|
-
response:
|
57
|
+
request: {klass: request},
|
58
|
+
response: {klass: response}
|
59
59
|
}.with_indifferent_access.deep_merge config.slice(*FORWARDER_OPTIONS)
|
60
60
|
end
|
61
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_valve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mkon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -120,28 +120,28 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - '='
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0.
|
123
|
+
version: 0.60.0
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - '='
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0.
|
130
|
+
version: 0.60.0
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rubocop-rspec
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - '='
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: 1.30.
|
137
|
+
version: 1.30.1
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - '='
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: 1.30.
|
144
|
+
version: 1.30.1
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: simplecov
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|