Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class WebRpcTransport

  1. Object
  2. WebRpcTransport

ImplementsRpcTransport

The backend’s RpcTransport: the chain clients of com.codename1.crypto.rpc (EvmRpc, EsploraClient, SolanaRpc) send through a WebClient, so they share its connection pool, timeouts and certificate checks.

WebClient web = new WebClient().setRequestTimeoutMillis(15000);
EvmRpc eth = new EvmRpc(new WebRpcTransport(web).header("Authorization", "Bearer " + key), url);

Create one per provider and share it; it holds no state per request.

Constructors

public WebRpcTransport(WebClient client)A transport over a client.
public WebRpcTransport()A transport over a client with every default.

Methods

public WebRpcTransport header(String name, String value)Adds a header sent with every request, for instance an API key.
public String send(String method, String url, String contentType, String body) throws IOExceptionSends one request and answers the response body.

Inherited methods

Constructor details

WebRpcTransport

public WebRpcTransport(WebClient client)
A transport over a client.

WebRpcTransport

public WebRpcTransport()
A transport over a client with every default.

Method details

header

public WebRpcTransport header(String name, String value)
Adds a header sent with every request, for instance an API key. Configure the transport before sharing it between threads.

send

public String send(String method, String url, String contentType, String body) throws IOException
Sends one request and answers the response body.

Parameters

method String
GET or POST
url String
the full URL
contentType String
the body’s media type, or null for a request without one
body String
the body, or null

Throws

RpcException
for a status outside 2xx, with the status and the body the server sent
IOException
when the request could not be made at all