JSONRPCResponseBuilder

DSL builder for constructing JSONRPCResponse instances.

Set either result for a success response or error for a failure response.

Type Parameters

T

The type of the result value.

E

The type of the error data.

Example:

val success = jsonRPCResponse<Int> {
id = RequestId(1)
result = 42
}

val failure = jsonRPCResponse<Nothing, Nothing> {
id = RequestId(1)
error = JSONRPCError.methodNotFound()
}

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The error object for a failed response. Mutually exclusive with result.

Link copied to clipboard

The request identifier to echo back.

Link copied to clipboard
var result: T?

The result value for a successful response. Mutually exclusive with error.

Functions

Link copied to clipboard

Builds a JSONRPCResponse from the configured properties.

Link copied to clipboard
inline fun error(init: JSONRPCErrorBuilder<E>.() -> Unit)

Builds the error inline using the JSONRPCErrorBuilder DSL.