| File | Date | Author | Commit |
|---|---|---|---|
| src | 2015-07-17 |
|
[c5d02c] Dealing with Task<Void> return types. |
| README.md | 2015-04-22 |
|
[23c892] Update README.md |
| pom.xml | 2015-07-23 |
|
[de74ba] Version 0.4.2 |
Allows calling JAX-RS REST interfaces with methods returning
CompletableFuture
or Orbit
Task.
This enables writing REST client code in a fluent asynchronous way.
The project orbit-rest-client depends only on the JAX-RS standard and it is in principle
compatible with any client library that provides javax.ws.rs.client.WebTarget.
It has been tested with
jersey-client.
public interface Hello
{
@GET
@Path("/")
Task<String> getHome();
}
public static void main(String args[])
{
WebTarget webTarget = getWebTarget("http://example.com");
Hello hello = new OrbitRestClient(webTarget).get(Hello.class);
Task<String> response = hello.getHome();
response.thenAccept(x -> System.out.println(x));
response.join();
}
// use any jax-rs client library to get javax.ws.rs.client.WebTarget
private static WebTarget getWebTarget(String host)
{
ClientConfig clientConfig = new ClientConfig();
Client client = ClientBuilder.newClient(clientConfig);
return client.target(host);
}
public interface Hello
{
@GET
@Path("/")
CompletableFuture<String> getHome();
}
public static void main(String args[])
{
WebTarget webTarget = getWebTarget("http://example.com");
Hello hello = new OrbitRestClient(webTarget).get(Hello.class);
CompletableFuture<String> response = hello.getHome();
response.thenAccept(x -> System.out.println(x));
response.join();
}
// use any jax-rs client library to get javax.ws.rs.client.WebTarget
private static WebTarget getWebTarget(String host)
{
ClientConfig clientConfig = new ClientConfig();
Client client = ClientBuilder.newClient(clientConfig);
return client.target(host);
}