- All Superinterfaces:
ServerResponse
A representation of a JSON-RPC response.
-
Method Summary
Modifier and TypeMethodDescriptionGet a complete response as a JSON object.error()
Get an error set on this response.Set a JSON-RPC error on this response with a code and a message.Set a JSON-RPC error on this response with a code, a message and some associated data.result()
Get the result set on this response.Set a result for this response as a JSON value.Set a result as an arbitrary object that can be mapped to JSON.rpcId()
Get the JSON-RPC ID set on this response.default JsonRpcResponse
rpcId
(int rpcId) Set a JSON-RPC ID for this response as an int.Set a JSON-RPC ID for this response.default JsonRpcResponse
Set a JSON-RPC ID for this response as a string.void
send()
Send this response over the wire to the client.status()
Get the status set on this response.status
(int status) Set an HTTP status for the underlying response.default JsonRpcResponse
Set an HTTP status for the underlying response.Methods inherited from interface io.helidon.webserver.http.ServerResponse
beforeTrailers, bytesWritten, contentLength, header, header, header, headers, isSent, next, outputStream, reroute, reroute, send, send, send, send, sink, streamFilter, streamResult, trailers, whenSent
-
Method Details
-
rpcId
Set a JSON-RPC ID for this response.- Parameters:
rpcId
- the ID- Returns:
- this response
-
rpcId
Set a JSON-RPC ID for this response as an int.- Parameters:
rpcId
- the ID- Returns:
- this response
-
rpcId
Set a JSON-RPC ID for this response as a string.- Parameters:
rpcId
- the ID- Returns:
- this response
-
result
Set a result for this response as a JSON value.- Parameters:
result
- the result- Returns:
- this response
- See Also:
-
result
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
Set a JSON-RPC error on this response with a code and a message.- Parameters:
code
- the error codemessage
- the error message- Returns:
- this response
- See Also:
-
error
Set a JSON-RPC error on this response with a code, a message and some associated data.- Parameters:
code
- the error codemessage
- the error messagedata
- the data- Returns:
- this response
- See Also:
-
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 isStatus.OK_200_CODE
.- Specified by:
status
in interfaceServerResponse
- Parameters:
status
- the status- Returns:
- this response
-
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 isStatus.OK_200
.- Specified by:
status
in interfaceServerResponse
- Parameters:
status
- the status- Returns:
- this response
-
rpcId
Get the JSON-RPC ID set on this response.- Returns:
- the ID
-
result
Get the result set on this response.- Returns:
- the result as a JSON value
-
error
Optional<JsonRpcError> 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 interfaceServerResponse
- 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 interfaceServerResponse
-
asJsonObject
JsonObject asJsonObject()Get a complete response as a JSON object.- Returns:
- a JSON object that represents the response
-