Quarkus
JSON-RPC server is integrated with Quarkus.
The entry point is the module io.yupiik.uship:jsonrpc-quarkus
.
Once added you can:
-
implement JSON-RPC methods using beans marked with
@JsonRpc
and methods with@JsonRpcMethod
, -
configure the base url of the OpenRPC value using
jsonrpc.baseUrl
(defaults to try to use localhost and the quarkus port) andjsonrpc.binding
to configure the servlet binding in microprofile-config (application.properties
), it defaults to/jsonrpc
.
Here is a sample:
@JsonRpc
@ApplicationScoped
public class MyEndpoints {
@JsonRpcMethod(name = "reverse")
public String reverse(@JsonRpcParam(value = "in") final String input) {
return new StringBuilder(input).reverse().toString();
}
@JsonRpcMethod(name = "header")
public String header(@JsonRpcParam(value = "name") final String name,
final HttpServletRequest request /*important: se jakarta one*/) {
return request.getHeader(name);
}
}