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 object params 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.

method set-id

method set-id(
    $id
) returns Nil

Sets and validates $.id

method set-jsonrpc

method set-jsonrpc(
    $jsonrpc
) returns Nil

Sets and validates $.jsonrpc

method set-method

method set-method(
    Str:D $!method
) returns Nil

Sets and validates $.method

method set-params

method set-params(
    $!params
) returns Nil

Sets $.params

method is-notification

method is-notification() returns Bool

Returns true if this request is just a notification (i.e. doesn't have id set)

SEE ALSO

Cro

AUTHOR

Vadim Belman [email protected]

LICENSE

Artistic License 2.0

See the LICENSE file in this distribution.

Cro::RPC::JSON v0.1.5

JSON-RPC 2.0 framework built on top of Cro

Authors

  • Vadim Belman

License

Artistic-2.0

Dependencies

Cro::HTTPJSON::FastJSON::MarshalCro::HTTP::RouterCro::HTTP::Router::WebSocket

Provides

  • Cro::RPC::JSON
  • Cro::RPC::JSON::Auth
  • Cro::RPC::JSON::BatchRequest
  • Cro::RPC::JSON::BatchResponse
  • Cro::RPC::JSON::Exception
  • Cro::RPC::JSON::Handler
  • Cro::RPC::JSON::META
  • Cro::RPC::JSON::Message
  • Cro::RPC::JSON::Metamodel::ClassHOW
  • Cro::RPC::JSON::Metamodel::ConcreteRoleHOW
  • Cro::RPC::JSON::Metamodel::MethodContainer
  • Cro::RPC::JSON::Metamodel::ParametricRoleHOW
  • Cro::RPC::JSON::Method
  • Cro::RPC::JSON::MethodResponse
  • Cro::RPC::JSON::Notification
  • Cro::RPC::JSON::Request
  • Cro::RPC::JSON::RequestParser
  • Cro::RPC::JSON::RequestParser::BodyStr
  • Cro::RPC::JSON::RequestParser::HTTP
  • Cro::RPC::JSON::RequestParser::WebSocket
  • Cro::RPC::JSON::Requestish
  • Cro::RPC::JSON::Response
  • Cro::RPC::JSON::ResponseSerializer
  • Cro::RPC::JSON::ResponseSerializer::HTTP
  • Cro::RPC::JSON::ResponseSerializer::WebSocket
  • Cro::RPC::JSON::Transform
  • Cro::RPC::JSON::Unmarshal
  • Cro::RPC::JSON::Utils

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.