line/armeria

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

开放

#3,707 创建于 2021年7月19日

 (10 条评论) (4 个反应) (1 位负责人)Java (863 个派生)batch import
good first issuenew feature

仓库指标

星标
 (4,552 个星标)
PR 合并指标
 (平均合并 5天 12小时) (30 天内合并 42 个 PR)

描述

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();

贡献者指南