Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

segmentio/retrofit-jsonrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

retrofit-jsonrpc

JSON-RPC with Retrofit.

Usage

Declare your RPC Service.

interface MultiplicationService {
    @JsonRPC("Arith.Multiply") @POST("/rpc")
    Call<Integer> multiply(@Body MultiplicationArgs args);
}

Register the JsonRPCConverterFactory while building your Retrofit instance. This must be done before any other converters are applied.

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("http://localhost:1234")
        .addConverterFactory(JsonRPCConverterFactory.create())
        .addConverterFactory(MoshiConverterFactory.create())
        .build();

Use Retrofit to build your service.

MultiplicationService service = retrofit.create(MultiplicationService.class);

Use your service.

service.multiply(MultiplicationArgs.create(2, 3)).execute().body(); // -> 6

Download

Note: Only snapshot releases are available currently.

Download the latest JAR or grab via Maven:

<dependency>
  <groupId>com.segment.retrofit.jsonrpc</groupId>
  <artifactId>jsonrpc</artifactId>
  <version>1.0.0-SNAPSHOT</version>
</dependency>

or Gradle:

compile 'com.segment.retrofit.jsonrpc:jsonrpc:1.0.0-SNAPSHOT'

Releases

No releases published

Packages

No packages published