Interface JsonRpcResponse

All Superinterfaces:
ServerResponse

public interface JsonRpcResponse extends ServerResponse
A representation of a JSON-RPC response.
  • Method Details

    • rpcId

      JsonRpcResponse rpcId(JsonValue rpcId)
      Set a JSON-RPC ID for this response.
      Parameters:
      rpcId - the ID
      Returns:
      this response
    • rpcId

      default JsonRpcResponse rpcId(int rpcId)
      Set a JSON-RPC ID for this response as an int.
      Parameters:
      rpcId - the ID
      Returns:
      this response
    • rpcId

      default JsonRpcResponse rpcId(String rpcId)
      Set a JSON-RPC ID for this response as a string.
      Parameters:
      rpcId - the ID
      Returns:
      this response
    • result

      JsonRpcResponse result(JsonValue result)
      Set a result for this response as a JSON value.
      Parameters:
      result - the result
      Returns:
      this response
      See Also:
    • result

      JsonRpcResponse result(Object object)
      Set a result as an arbitrary object that can be mapped to JSON. This method will serialize the parameter using JSONB.
      Parameters:
      object - the object
      Returns:
      this response
      Throws:
      JsonException - if an error occurs during serialization
      See Also:
    • error

      JsonRpcResponse error(int code, String message)
      Set a JSON-RPC error on this response with a code and a message.
      Parameters:
      code - the error code
      message - the error message
      Returns:
      this response
      See Also:
    • error

      JsonRpcResponse error(int code, String message, JsonValue data)
      Set a JSON-RPC error on this response with a code, a message and some associated data.
      Parameters:
      code - the error code
      message - the error message
      data - the data
      Returns:
      this response
      See Also:
    • status

      JsonRpcResponse status(int status)
      Set an HTTP status for the underlying response. Normally this will be set by Helidon, but this method allows to override the default values. The default value is Status.OK_200_CODE.
      Specified by:
      status in interface ServerResponse
      Parameters:
      status - the status
      Returns:
      this response
    • status

      default JsonRpcResponse status(Status status)
      Set an HTTP status for the underlying response. Normally this will be set by Helidon, but this method allows to override the default values. The default value is Status.OK_200.
      Specified by:
      status in interface ServerResponse
      Parameters:
      status - the status
      Returns:
      this response
    • rpcId

      Get the JSON-RPC ID set on this response.
      Returns:
      the ID
    • result

      Optional<JsonValue> result()
      Get the result set on this response.
      Returns:
      the result as a JSON value
    • error

      Get an error set on this response.
      Returns:
      the error
    • status

      Status status()
      Get the status set on this response.
      Specified by:
      status in interface ServerResponse
      Returns:
      the status
    • send

      void send()
      Send this response over the wire to the client. This method blocks until the response is delivered.
      Specified by:
      send in interface ServerResponse
    • asJsonObject

      JsonObject asJsonObject()
      Get a complete response as a JSON object.
      Returns:
      a JSON object that represents the response