Request
NAME
Cro::RPC::JSON::Request
- prepared JSON-RPC request object
ROLES
Does Cro::RPC::JSON::Message, Cro::RPC::JSON::Requestish
ATTRIBUTES
$.jsonrpc
- JSON-RPC version. Currently this attribute always contains "2.0"$.id
- JSON-RPC request id. Undefined if the request is a notification.Str $.method
ā request method name$.params
ā request parameters as parsed from JSON-RPC request objectparams
key%.data
ā parsed full request JSON object.Str $.invalid
ā undefined for valid requests. Otherwise contains error message explaining the cause.$.batch
- if request is part of a batch request then this attribute points to corresponding Cro::RPC::JSON::BatchRequest object
METHODS
set-jsonrpc($jsonrpc)
, set-id($id)
, set-method(Str:D $method)
, set-params($params)
Set corresponding attributes.
set-jsonrpc
and set-id
throw X::Cro::RPC::JSON::InvalidRequest
if supplied value is invalid.
is-notification(--
Bool:D)>
Returns True if request is a notification, i.e. when id
key
is not specified.
jrpc-response(|c)
Returns a Cro::RPC::JSON::MethodResponse object paired with the current request. Most of the time this method must be given preference over creating a method response object manually.
proto respond()
This method is what must be used to respond to a request. It creates a new response object if necessary, completes it, and them calls emit with it.
multi respond(Any:D $data)
Takes $data
and sets it as the result of current request response.
multi respond(Exception:D :$exception)
Takes an exception and produces correct error response from it.
multi respond()
If request belongs to a batch then delegates to the batch request object. Otherwise simply emits response object.
SEE ALSO
AUTHOR
Vadim Belman <[email protected]>
LICENSE
Artistic License 2.0
See the LICENSE file in this distribution.