@@ -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.2 </version >
17+ <version >1.5 </version >
1818</dependency >
1919```
2020
@@ -42,24 +42,25 @@ From HttpClientContext:
4242 - Build the url via path(), matrixParam(), queryParam()
4343 - Optionally set headers(), cookies() etc
4444 - Optionally specify a request body (JSON, form, or raw BodyPublisher)
45- - Http verbs - get (), post (), put (), delete ()
45+ - Http verbs - GET (), POST (), PUT (), PATCH(), DELETE(), HEAD(), TRACE ()
4646 - Optionally return response body as a bean, list of beans, or raw
4747
4848## Examples
4949
5050GET as String
5151``` java
52- final HttpResponse<String > hres = clientContext. request()
53- .path(" hello" )
54- .get() . asString();
55-
52+ final HttpResponse<String > hres = clientContext. request()
53+ .path(" hello" )
54+ . GET ()
55+ .asString();
5656```
5757
5858GET as json to single bean
5959``` java
6060final HelloDto bean = clientContext. request()
6161 .path(" hello/there" )
62- .get(). bean(HelloDto . class);
62+ . GET ()
63+ .bean(HelloDto . class);
6364```
6465
6566POST a bean as json request body
@@ -68,18 +69,19 @@ HelloDto bean = new HelloDto(12, "rob", "other");
6869
6970final HttpResponse<Void > res = clientContext. request()
7071 .path(" hello/savebean" )
71- .body(bean). post()
72+ .body(bean)
73+ . POST ()
7274 .asDiscarding();
7375
7476assertThat(res. statusCode()). isEqualTo(201 );
75-
7677```
7778
7879GET as json to list of beans
7980``` java
8081final List<HelloDto > beans = clientContext. request()
8182 .path(" hello" )
82- .get(). list(HelloDto . class);
83+ . GET ()
84+ .list(HelloDto . class);
8385```
8486
8587Path
@@ -88,13 +90,15 @@ final HttpResponse<String> res = clientContext.request()
8890 .path(" hello" )
8991 .path(" withMatrix" )
9092 .path(" 2011" )
91- .get(). asString();
93+ . GET ()
94+ .asString();
9295
9396// is the same as ...
9497
9598final HttpResponse<String > res = clientContext. request()
9699 .path(" hello/withMatrix/2011" )
97- .get(). asString();
100+ . GET ()
101+ .asString();
98102```
99103
100104MatrixParam
@@ -105,7 +109,7 @@ final HttpResponse<String> httpRes = clientContext.request()
105109 .matrixParam(" country" , " nz" )
106110 .path(" foo" )
107111 .matrixParam(" extra" , " banana" )
108- .get (). asString();
112+ . GET (). asString();
109113```
110114
111115QueryParam
@@ -114,7 +118,7 @@ final List<HelloDto> beans = clientContext.request()
114118 .path(" hello" )
115119 .queryParam(" sortBy" , " name" )
116120 .queryParam(" maxCount" , " 100" )
117- .get (). list(HelloDto . class);
121+ . GET (). list(HelloDto . class);
118122```
119123
120124FormParam
@@ -125,13 +129,13 @@ final HttpResponse<Void> res = clientContext.request()
125129 .formParam(" email" , " user@foo.com" )
126130 .formParam(" url" , " http://foo.com" )
127131 .formParam(" startDate" , " 2020-12-03" )
128- .post ()
132+ . POST ()
129133 .asDiscarding();
130134
131135assertThat(res. statusCode()). isEqualTo(201 );
132136```
133137
134- ## Currently NO support for POSTing multipart-form
138+ ## Currently, NO support for POSTing multipart-form
135139
136140## Auth token
137141
@@ -149,7 +153,7 @@ Built in support for obtaining and setting an Authorization token.
149153 .url(" https://foo/v2/token" )
150154 .header(" content-type" , " application/json" )
151155 .body(authRequestAsJson())
152- .post ()
156+ . POST ()
153157 .bean(AuthTokenResponse . class);
154158
155159 Instant validUntil = Instant . now(). plusSeconds(res. expires_in). minusSeconds(60 );
0 commit comments