line/armeria

Provide a way to send a JSON object with `WebClient`

Open

#3,707 opened on Jul 19, 2021

View on GitHub
 (10 comments) (4 reactions) (1 assignee)Java (4,552 stars) (863 forks)batch import
good first issuenew feature

Description

JSON is the dominant exchange format for REST API. However, Armeria's WebClient does not provide any JSON-specific APIs. I believe it should be useful additions if we provide:

WebClient client = WebClient.of();
// Send a serialized JSON object with "applicaiton/json"
HttpResponse response = client.postJson("/items", new MyItem()); 
HttpResponse response = client.putJson("/items", new MyItem());
HttpResponse response = client.patchJson("/items", new MyItem());

HttpResponse response = client.prepare()
                              .post("/items")
                              .contentJson(new MyItem())
                              .execute();

Contributor guide

Provide a way to send a JSON object with `WebClient` · line/armeria#3707 | Good First Issue