json_rpc_adapter 0.7.0 copy "json_rpc_adapter: ^0.7.0" to clipboard
json_rpc_adapter: ^0.7.0 copied to clipboard

HTTP client and shelf server adapters for easier JSON-RPC, with efficient binary encodings (optional mirrors for automatic binding).

HTTP client and shelf server adapters for easier JSON-RPC #

Automatic RPC bindings using mirrors #

Takes an abstract class API definition with at most one argument on each method:

abstract class TestApi {
  Future<ObjRs> incrementObject(ObjRq rq);
  Future<String> incrementInt(int x);

  Future<void> setter(int x);
  /// Note: `int?` is not supported here yet, only non-null `int`.
  Future<int?> getter();
}

Use reflection to get a shelf handler:

    final api = TestApiImpl();
    final handler = JsonRpcShelfHandler()
      ..registerApi<TestApi>(api);

User reflection to get a http-based client:

class TestApiClient extends ReflectedApiClient<TestApi> implements TestApi {
  TestApiClient(super.client);
}
    final client = JsonRpcHttpClient(
      endpoint: 'http://localhost:8080/',
    );
    final reflectedApi = TestApiClient(client);

See more #

See usage in the test directory: https://github.com/agilord/json_rpc_adapter/tree/master/test

1
likes
160
points
148
downloads

Publisher

verified publisheragilord.com

Weekly Downloads

HTTP client and shelf server adapters for easier JSON-RPC, with efficient binary encodings (optional mirrors for automatic binding).

Repository (GitHub)

Topics

#json-rpc #rpc

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

http, json_rpc_2, shelf

More

Packages that depend on json_rpc_adapter