File tree Expand file tree Collapse file tree 3 files changed +16
-14
lines changed
Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ def call(env)
88 result = handle_single ( jsonrpc_request )
99 jsonrpc_response ( result )
1010 elsif jsonrpc_notification?
11- handle_single ( jsonrpc_request )
11+ handle_single ( jsonrpc_notification )
1212 jsonrpc_notification_response
1313 else
1414 result = handle_batch ( jsonrpc_batch )
@@ -18,10 +18,10 @@ def call(env)
1818
1919 private
2020
21- def handle_single ( jsonrpc_request )
22- params = jsonrpc_request . params
21+ def handle_single ( request_or_notification )
22+ params = request_or_notification . params
2323
24- case jsonrpc_request . method
24+ case request_or_notification . method
2525 when 'add'
2626 addends = params . is_a? ( Array ) ? params : params [ 'addends' ] # Handle positional and named arguments
2727 addends . sum
Original file line number Diff line number Diff line change @@ -13,14 +13,14 @@ def jsonrpc_method(method_name, &block)
1313 end
1414 end
1515
16- def jsonrpc_batch? = jsonrpc_request . is_a? ( JSONRPC :: BatchRequest )
17- def jsonrpc_notification? = jsonrpc_request . is_a? ( JSONRPC :: Notification )
18- def jsonrpc_request? = jsonrpc_request . is_a? ( JSONRPC :: Request )
16+ def jsonrpc_batch? = @env . key? ( 'jsonrpc.batch' )
17+ def jsonrpc_notification? = @env . key? ( 'jsonrpc.notification' )
18+ def jsonrpc_request? = @env . key? ( 'jsonrpc.request' )
1919
2020 # Get the current JSON-RPC request object
21+ def jsonrpc_batch = @env [ 'jsonrpc.batch' ]
2122 def jsonrpc_request = @env [ 'jsonrpc.request' ]
2223 def jsonrpc_notification = @env [ 'jsonrpc.notification' ]
23- def jsonrpc_batch = @env [ 'jsonrpc.batch' ]
2424
2525 # Create a JSON-RPC response
2626 def jsonrpc_response ( result )
Original file line number Diff line number Diff line change @@ -51,14 +51,16 @@ def handle_jsonrpc_request(req)
5151 return json_response ( 200 , validation_errors ) if validation_errors
5252
5353 # Pass the request to the next app in the stack
54- status , headers , body = @app . call ( req . env )
54+ # status, headers, body = @app.call(req.env)
5555
5656 # For notifications, ensure we return 204 No Content
57- if parsed . is_a? ( Notification )
58- [ 204 , { } , [ ] ]
59- else
60- [ status , headers , body ]
61- end
57+ # if parsed.is_a?(Notification)
58+ # [204, {}, []]
59+ # else
60+ # [status, { 'content-type' => 'application/json' }, [body.is_a?(String) ? body : JSON.generate(body)]]
61+ # end
62+
63+ @app . call ( req . env )
6264 end
6365
6466 def collect_validation_errors ( parsed )
You can’t perform that action at this time.
0 commit comments