Interface JsonRpcResponse
- 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 from an object that can be mapped to a JSON object by Helidon JSON binding.rpcId()Get the JSON-RPC ID set on this response.default JsonRpcResponserpcId(int rpcId) Set a JSON-RPC ID for this response as an int.Set a JSON-RPC ID for this response.default JsonRpcResponseSet a JSON-RPC ID for this response as a string.voidsend()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 JsonRpcResponseSet an HTTP status for the underlying response.Methods inherited from interface ServerResponse
automaticContentEncoding, beforeSend, beforeTrailers, bytesWritten, contentEncoder, contentLength, header, header, header, headers, isResponseHandled, isSent, next, outputStream, reroute, reroute, send, send, send, send, sink, streamFilter, streamResult, trailers, whenSentModifier and TypeMethodDescriptiondefault ServerResponseautomaticContentEncoding(boolean enabled) Configure whether the WebServer response layer may automatically encode the response entity using the listener content encoding context.default ServerResponsebeforeSend(Runnable listener) Executed right before the first byte is written to the socket (including response status and headers).default ServerResponsebeforeTrailers(Consumer<ServerResponseTrailers> beforeTrailers) Callback to update any last minute trailers before they are written to the output stream.longNumber of bytes written to response.default ServerResponsecontentEncoder(ContentEncoder encoder) Configure an explicit response content encoder.default voidcontentLength(long length) Configure a content length header for this response.Set header with a value.default ServerResponseheader(HeaderName name, String... values) Set a header.default ServerResponseNot optimized method for setting a header.headers()Response headers (mutable).default booleanWhether this response has already been handled by the application.booleanisSent()Whether this response has been sent.next()Continue processing with the next route (and if none found, return aStatus.NOT_FOUND_404).Alternative way to send an entity, using an output stream.Re-route using a different path.Re-route using a different path and query.voidsend(byte[] bytes) Send a byte array response.default voidsend(byte[] bytes, int position, int length) Send a byte array response.voidSend an entity, aMediaContextwill be used to serialize the entity.default voidSend an entity if present, throwNotFoundExceptionif empty.default <T extends Sink<?>>
Tsink(GenericType<T> sinkType) Returns a sink from this response based on the sink type.voidstreamFilter(UnaryOperator<OutputStream> filterFunction) Configure a custom output stream to wrap the output stream of the response.voidstreamResult(String result) Description of the result of output stream processing.trailers()Response trailers (mutable).Completed when last byte is buffered for socket write.
-
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 from an object that can be mapped to a JSON object by Helidon JSON binding.Custom Java types passed to this method should be annotated with
io.helidon.json.binding.Json.Entity.- Parameters:
object- the object- Returns:
- this response
- Throws:
JsonBindingException- if an error occurs during mapping- 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:
statusin 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:
statusin interfaceServerResponse- Parameters:
status- the status- Returns:
- this response
-
rpcId
-
result
-
error
-
status
Status status()Get the status set on this response.- Specified by:
statusin 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:
sendin interfaceServerResponse
-
asJsonObject
JsonObject asJsonObject()Get a complete response as a JSON object.- Returns:
- a JSON object that represents the response
-