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 objectparamskey%.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.
method set-id
method set-id(
$id
) returns NilSets and validates $.id
method set-jsonrpc
method set-jsonrpc(
$jsonrpc
) returns NilSets and validates $.jsonrpc
method set-method
method set-method(
Str:D $!method
) returns NilSets and validates $.method
method set-params
method set-params(
$!params
) returns NilSets $.params
method is-notification
method is-notification() returns BoolReturns true if this request is just a notification (i.e. doesn't have id set)
SEE ALSO
AUTHOR
Vadim Belman [email protected]
LICENSE
Artistic License 2.0
See the LICENSE file in this distribution.