Skip to content

Commit ca89f8e

Browse files
committed
Update README
1 parent d54269a commit ca89f8e

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

README.md

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A light weight wrapper to the JDK 11+ Java Http Client
1414
<dependency>
1515
<groupId>io.avaje</groupId>
1616
<artifactId>avaje-http-client</artifactId>
17-
<version>1.5</version>
17+
<version>1.6</version>
1818
</dependency>
1919
```
2020

@@ -49,25 +49,42 @@ From HttpClientContext:
4949

5050
GET as String
5151
```java
52-
final HttpResponse<String> hres = clientContext.request()
52+
HttpResponse<String> hres = clientContext.request()
5353
.path("hello")
5454
.GET()
5555
.asString();
5656
```
5757

5858
GET as json to single bean
5959
```java
60-
final HelloDto bean = clientContext.request()
61-
.path("hello/there")
60+
Customer customer = clientContext.request()
61+
.path("customers").path(42)
6262
.GET()
63-
.bean(HelloDto.class);
63+
.bean(Customer.class);
6464
```
6565

66+
GET as json to a list of beans
67+
```java
68+
List<Customer> list = clientContext.request()
69+
.path("customers")
70+
.GET()
71+
.list(Customer.class);
72+
```
73+
74+
GET as `application/x-json-stream` as a stream of beans
75+
```java
76+
Stream<Customer> stream = clientContext.request()
77+
.path("customers/all")
78+
.GET()
79+
.stream(Customer.class);
80+
```
81+
82+
6683
POST a bean as json request body
6784
```java
6885
HelloDto bean = new HelloDto(12, "rob", "other");
6986

70-
final HttpResponse<Void> res = clientContext.request()
87+
HttpResponse<Void> res = clientContext.request()
7188
.path("hello/savebean")
7289
.body(bean)
7390
.POST()
@@ -76,35 +93,28 @@ final HttpResponse<Void> res = clientContext.request()
7693
assertThat(res.statusCode()).isEqualTo(201);
7794
```
7895

79-
GET as json to list of beans
80-
```java
81-
final List<HelloDto> beans = clientContext.request()
82-
.path("hello")
83-
.GET()
84-
.list(HelloDto.class);
85-
```
8696

8797
Path
8898
```java
89-
final HttpResponse<String> res = clientContext.request()
90-
.path("hello")
91-
.path("withMatrix")
92-
.path("2011")
99+
HttpResponse<String> res = clientContext.request()
100+
.path("customers")
101+
.path("42")
102+
.path("contacts")
93103
.GET()
94104
.asString();
95105

96106
// is the same as ...
97107

98-
final HttpResponse<String> res = clientContext.request()
99-
.path("hello/withMatrix/2011")
108+
HttpResponse<String> res = clientContext.request()
109+
.path("customers/42/contacts")
100110
.GET()
101111
.asString();
102112
```
103113

104114
MatrixParam
105115
```java
106-
final HttpResponse<String> httpRes = clientContext.request()
107-
.path("hello")
116+
HttpResponse<String> httpRes = clientContext.request()
117+
.path("books")
108118
.matrixParam("author", "rob")
109119
.matrixParam("country", "nz")
110120
.path("foo")
@@ -114,17 +124,17 @@ final HttpResponse<String> httpRes = clientContext.request()
114124

115125
QueryParam
116126
```java
117-
final List<HelloDto> beans = clientContext.request()
118-
.path("hello")
127+
List<Product> beans = clientContext.request()
128+
.path("products")
119129
.queryParam("sortBy", "name")
120130
.queryParam("maxCount", "100")
121-
.GET().list(HelloDto.class);
131+
.GET().list(Product.class);
122132
```
123133

124134
FormParam
125135
```java
126-
final HttpResponse<Void> res = clientContext.request()
127-
.path("hello/saveform")
136+
HttpResponse<Void> res = clientContext.request()
137+
.path("register/user")
128138
.formParam("name", "Bazz")
129139
.formParam("email", "user@foo.com")
130140
.formParam("url", "http://foo.com")

0 commit comments

Comments
 (0)