Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class WebRpcTransport
- Object
- 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
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 IOExceptionSends one request and answers the response body.
Parameters
methodStringGETorPOSTurlString- the full URL
contentTypeString- the body’s media type, or
nullfor a request without one bodyString- 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