use of io.servicetalk.examples.http.serialization.json.CreatePojoRequest in project servicetalk by apple.
the class PojoClient method main.
public static void main(String[] args) throws Exception {
try (HttpClient client = HttpClients.forSingleAddress("localhost", 8080).build()) {
client.request(client.post("/pojos").payloadBody(new CreatePojoRequest("value"), REQ_SERIALIZER)).whenOnSuccess(resp -> {
System.out.println(resp.toString((name, value) -> value));
System.out.println(resp.payloadBody(RESP_SERIALIZER));
}).toFuture().get();
}
}
use of io.servicetalk.examples.http.serialization.json.CreatePojoRequest in project servicetalk by apple.
the class BlockingPojoClient method main.
public static void main(String[] args) throws Exception {
try (BlockingHttpClient client = HttpClients.forSingleAddress("localhost", 8080).buildBlocking()) {
HttpResponse resp = client.request(client.post("/pojos").payloadBody(new CreatePojoRequest("value"), REQ_SERIALIZER));
System.out.println(resp.toString((name, value) -> value));
System.out.println(resp.payloadBody(RESP_SERIALIZER));
}
}
use of io.servicetalk.examples.http.serialization.json.CreatePojoRequest in project servicetalk by apple.
the class PojoUrlClient method main.
public static void main(String[] args) throws Exception {
try (HttpClient client = HttpClients.forMultiAddressUrl().build()) {
client.request(client.post("http://localhost:8080/pojos").payloadBody(new CreatePojoRequest("value"), REQ_SERIALIZER)).whenOnSuccess(resp -> {
System.out.println(resp.toString((name, value) -> value));
System.out.println(resp.payloadBody(RESP_SERIALIZER));
}).toFuture().get();
}
}
use of io.servicetalk.examples.http.serialization.json.CreatePojoRequest in project servicetalk by apple.
the class BlockingPojoUrlClient method main.
public static void main(String[] args) throws Exception {
try (BlockingHttpClient client = HttpClients.forMultiAddressUrl().buildBlocking()) {
HttpResponse resp = client.request(client.post("http://localhost:8080/pojos").payloadBody(new CreatePojoRequest("value"), REQ_SERIALIZER));
System.out.println(resp.toString((name, value) -> value));
System.out.println(resp.payloadBody(RESP_SERIALIZER));
}
}
use of io.servicetalk.examples.http.serialization.json.CreatePojoRequest in project servicetalk by apple.
the class BlockingPojoStreamingClient method main.
public static void main(String[] args) throws Exception {
try (BlockingStreamingHttpClient client = HttpClients.forSingleAddress("localhost", 8080).buildBlockingStreaming()) {
BlockingStreamingHttpResponse response = client.request(client.post("/pojos").payloadBody(asList(new CreatePojoRequest("value1"), new CreatePojoRequest("value2"), new CreatePojoRequest("value3")), REQ_STREAMING_SERIALIZER));
System.out.println(response.toString((name, value) -> value));
// the full response payload body is drained in case of exceptions
try (BlockingIterator<PojoResponse> payload = response.payloadBody(RESP_STREAMING_SERIALIZER).iterator()) {
while (payload.hasNext()) {
System.out.println(payload.next());
}
}
}
}
Aggregations