jsonrpc-rails 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 +4 -4
- data/README.md +3 -3
- data/lib/jsonrpc_rails/controller_helpers.rb +3 -3
- data/lib/jsonrpc_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93b8692cfb780990697a06219f80c323096bd5b12d21b95ec0a70e83dcbe555c
|
4
|
+
data.tar.gz: a3a15cc185bfb704d6a11cd2085be7beb291c20e727ef9cce317d4b993d5efc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 305bde8d1013629a31736c9da2de66a90e6d0e860311b784cbac65615646a24ae6460b1cb21699c8c79141027b65c8a988b6f20fbcdbad6d7e1425125fe458df
|
7
|
+
data.tar.gz: 232740f9c3756071955993b87f7f8ae4832d6159dd6273cd71a6b944003dbc1d68f32692addab5b3ea90d04bfc32908f4572da0791b778e7fdd8f4394abe640d
|
data/README.md
CHANGED
@@ -111,9 +111,9 @@ In your controller action, you can access the validated payload like this:
|
|
111
111
|
class MyApiController < ApplicationController
|
112
112
|
# POST /rpc
|
113
113
|
def process
|
114
|
-
if
|
114
|
+
if jsonrpc_params_batch?
|
115
115
|
# ── batch ───────────────────────────────────────────────────────────────
|
116
|
-
responses =
|
116
|
+
responses = jsonrpc_params.filter_map { |req| handle_single_request(req) } # strip nil (notifications)
|
117
117
|
|
118
118
|
if responses.empty?
|
119
119
|
head :no_content
|
@@ -123,7 +123,7 @@ class MyApiController < ApplicationController
|
|
123
123
|
end
|
124
124
|
else
|
125
125
|
# ── single ──────────────────────────────────────────────────────────────
|
126
|
-
response = handle_single_request(
|
126
|
+
response = handle_single_request(jsonrpc_params)
|
127
127
|
|
128
128
|
if response # request (has id)
|
129
129
|
render jsonrpc: response.result,
|
@@ -7,13 +7,13 @@ module JSONRPC_Rails
|
|
7
7
|
included do
|
8
8
|
# Returns a JSON_RPC::Request / Notification / Response
|
9
9
|
# or an Array of them for batch calls.
|
10
|
-
def
|
10
|
+
def jsonrpc_params
|
11
11
|
request.env[:jsonrpc]
|
12
12
|
end
|
13
13
|
|
14
14
|
# Convenience boolean
|
15
|
-
def
|
16
|
-
|
15
|
+
def jsonrpc_params_batch?
|
16
|
+
jsonrpc_params.is_a?(Array)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|